I tried Fontanka16 solution, but it did not work, it turned out that my DbContext class was missing its default constructor defining the target CE database.
These are my steps summary:
- Installed the Nuget package EntityFramework.SqlServerCompact.
-
Added the default constructor to my DbContext class.
public class SchoolContext : DbContext
{
public SchoolContext() : base(“School“) { }
…
} -
My connection string is:
<add name="SchoolContext" connectionString="Data Source=|DataDirectory|School.sdf" providerName="System.Data.SqlServerCe.4.0" />
Then it worked.