I'm trying to update project that makes use of an SQL Server Compact 4.0 database file, using standard SQL statements to insert/query etc, to use Entity Framework 4 (using VS2010 and .NET 4, so can't use a higher EF)
Since VS2010 doesn't have design time support for From Database Entity Framework configuration with SQL Server Compact 4.0, I followed the instructions posted by ErikEJ http://erikej.blogspot.co.uk/2010/11/using-entity-framework-with-sql-server.html
Specifically the part about creating a schema exactly the same as the 4.0 version, using that to set up your entities, then pointing your configuration at the 4.0 provider and database.
After updating the app.config
and .edmx
files to point at 4.0 (as stated in the article), I get an
Error 175: The specified store provider cannot be found in the configuration, or is not valid
After reading more about the error, I came across this answer: Using Entity Framework with an SQL Compact Private Installation
So I added:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
to my app.config
, but this made no difference.
Is there something I'm missing?
Thanks in advance!
Install my free SQL Server Compact Toolbox Visual Studio extension, connect to the database and use the "Generate Code" => "Add Entity Data Model to Current Project" feature