I have recently come across this same problem whilst trying to use SqlServerCe with Entity Framework.
I have managed to work around this issue by using the Code-Based configuration features available in Entity Framework 6.
All you need to do is remove the <entityframeowrk>
and <system.data>
tags from your app.config
and include a class similar to the following in your project:
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.SqlServerCompact;
using System.Data.SqlServerCe;
namespace Data
{
public class DatabaseConfiguration : DbConfiguration
{
public DatabaseConfiguration()
{
SetExecutionStrategy("System.Data.SqlServerCe.4.0", () => new DefaultExecutionStrategy());
SetProviderFactory("System.Data.SqlServerCe.4.0", new SqlCeProviderFactory());
SetProviderServices("System.Data.SqlServerCe.4.0", SqlCeProviderServices.Instance);
}
}
}
Entity framework will then automatically pick this up for you and use it. A note to watch out for is that configuration in the app.config
will overwrite anything that appears in this class.
Also if you do not want to include this class in your data layer, see the Moving DbConfiguration section here.