Take the 2-minute tour ×

My application uses SQL Server Ce for the database and Entity Framework as the ORM. Now I'm trying to switch to SQL Server Express but I'm having trouble doing so.


So after banging my head for 3 hours I finally figured out that you cannot use an Entity model generated from a SQL Server CE database against a SQL Server (in my case Express version).

I used a Diff program to view the generated files (Designer.cs) for both databases and I noticed these differences in the file:

SQL Server CE                          SQL Server 
FK__Download__000000000000003F         FK__Download__PlaneI__0519C6AF 

So I have to create two entity models, but how can I interchange between the two in my program?

If I create two entity models, I'll have two classes with the same object names.

Thanks in advance

share|improve this question
add comment

1 Answer

The EDMX file actually consists out of three parts.

  • CSDL, your conceptual model
  • SSDL, the storage model
  • MSL, the mapping between those two.

Normally these three parts are embedded in as a resource in your assembly and the connection string that you use tells the runtime to look for them in that assembly.

You can however use physical files and deploy them with your application. In such a way you can use the same CSDL but a different set of SSDL/MSL for the specific database. In that way you can reuse your entity model against both your SqlCE database and a SQL Server database.

Here you can find a blog post about swapping EF metadata

share|improve this answer
Thanks Kort for the answer, but unfortunately in this case this doesn't work. When I changed the connection string + the information in the ssdl file to reflect using Sql Express, I got a weird exception when trying to query data. The entity classes created by using Sql Ce are different from the entity classes created from a Sql Server. Like I mentioned above, looking at the automatically generated entity class I saw alot of differences in the two classes. –  Armen B. Dec 5 '11 at 15:19
add comment

Your Answer


