Here we encounter the first problem. The ADO.NET Entity Data Model generator in Visual Studio 2010 does not seem to support ADO.NET connection strings to the SQL Server 4.0 Compact Edition. Even adding the DbProviderFactory for SQLServer 4.0 Compact in the machine.config does not seem to work.

To the rescue comes the command line ADO.NET Entity Data Model generator 2 source code which can be downloaded here EdmGen2.exe.

EdmGen2 is a command-line tool for the Microsoft ADO.NET Entity Framework. The tool can be used as a replacement for the EdmGen.exe tool that ships with the .Net framework 3.5 SP1. EdmGen.exe can only read and write the CSDL, SSDL & MSL file formats. However, EdmGen2.exe can read and write the EDMX file format used by the Visual Studio design tools. Additionally, EdmGen2.exe can translate between EDMX and CSDL, SSDL & MSL formats, and the source code can act as examples on using the tooling APIs defined in the System.Data.Entity.Design assembly.

The first thing I found trying to run this tool with the following command line

was that the database I wanted to use was a SqlServer CE 3.5 database.

This was not obvious since the EdmGen2 tool just silently failed with no output. However running it through the debugger with the above command line parameters, yielded the following error.

"error 6003: The underlying provider failed on Open.

The database file has been created by an earlier version of SQL Server Compact. Please upgrade using SqlCeEngine.Upgrade() method."

At this point in time, I am slowly beginning to wonder if going down this path using Sql Server CE is worth it (since I most likely will never use it professionally), or if I am missing something obvious (which is not entirely unlikely). But alas being stubborn I quickly created a small windows app with the following code

This allowed me to update the database file to a Sql Server 4.0 compatible database.After copying the database to App_Data and invoking the EdmGen2 tool it now worked great and I could start mapping the ADO.NET Entity models to my domain models.

I will not provide the updated Northwind database here but you can download the NorthwindDBUpdater project and update the database yourself (I guess you should be able to use it to update any CE database, not just Northwind.)