No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'
After installing the EntityFramework.SqlServerCompact nuget package, check that your app.config contains the following (as per @ErikEJ's comment above):
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
(You can leave the line for SqlClient even though you don't really need it.)
ErikEJ has pointed this out, but I'd like to highlight the fact, you MUST remember to install the Nuget package
EntityFramework.SqlServerCompact
I tried following the recommended answer, but didn't realise I didn't have the required NuGet package the App.config was referencing.
I met the issue in my unit tests. The tricky thing was that the error had appeared not constantly. I managed to solve it by adding the follwing class my my unit tests solution:
public static class Trick
{
public static void FixEfProviderServicesProblem()
{
// this commented line should be used for SQL Server provider
//var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
// this is used for SQL Server CE provider
var instance = System.Data.Entity.SqlServerCompact.SqlCeProviderServices.Instance;
}
}