1
votes

I am trying to use an existing SQL CE 4 database in my windows phone application. I have setup the schema. Creating the context seems fine using my connection string of "Data Source='appdata:/Items.sdf';mode='read only'"

However when I try to query the database I get the following error:

Incompatible Database Version. If this was a compatible file, run repair. For other cases refer to documentation. [ Db version = 4000000,Requested version = 3505053,File name = Items.sdf ]

The Items.sdf database was created using EntityFramework 4.1 Code First.

Any ideas on how to make this compatible? Should I be doing something else?

2
It is probably better to use LINQ to SQL and SQLMetal for database creation on desktop. - ErikEJ

2 Answers

1
votes

Windows Phone is using SQL Compact 3.5, not 4.0 as its engine. You'll need to create a version 3.5-compatible file (not sure if EF can do that offhand).

0
votes

Windows Phone 7 Mango has introduced the SQL CE for Windows Phone as a viable solution for local database. The SQL CE engine is a sort of hybrid because is coming from the 4.0 version, without all the new things related to the web scenario but not usefull related to the smatphone usage scenario. The Database file version is indeed the 3.5 version. The Code First is the only available option by Microsoft, but Erik Ejlskov Jensen has created a very usefull Visual Studio Add-in named SQL Server Compact Toolbox that can build the DataContext with all the needed classes, so also the Database First is freely available.