Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup EF4 data source for SQL Compact 4

I've installed visual studio 2010 SP1, EF 4.1, SQL Compact 4.0 with vs tools. Everything is appears ok, except I can't use SQL Compact 4 as a data source for Entity framework through the wizard. The only alternative is SQL Compact 3.5.

Is there a patch or something I'm missing? Has anyone got EF 4 and SQL Compact 4.0 working together without hacking everything.

like image 242
Nickz Avatar asked Apr 13 '11 06:04

Nickz


2 Answers

No you're not missing something. In VS2010SP1 SQLCE40 is supported only in web projects. You can get 4.0 EDM support with SQL Server Compact Toolbox which adds the functionality as an add-in to VS2010SP1 (this shows up in the Server Explorer tab as an icon). It works well at creating the edmx file and a modelname.App.Config file that you can use to grab the connection string for your projects App.Config file. But you need to do most all of the work over in the Server Explorer and not in the Solution Explorer which will complain about adding SQLCE40 dbs. Note that if you don't use the db name (default) as the model name you will have to edit the connection string but this is easy. Once the edmx is in place and the connection string is copied over to the App.Config file. You can use the visual edmx designer the same as you could with SQLCE35 dbs. Also be aware that Microsoft SQL Server Management Studio does not support SQLCE40 dbs either.

like image 114
pn1 dude Avatar answered Nov 16 '22 09:11

pn1 dude


For web projects, once SP1 is installed, EDM Wizard will support SQL CE 4, for other projects 3.5 only. You could try my SQL Server Compact Toolbox add-in, that generates edmx files using edmgen2 in any applicable project type.

like image 40
ErikEJ Avatar answered Nov 16 '22 11:11

ErikEJ