I'm using the latest ASP.NET MVC, Identity and Entity Framework.
The sample Identity project uses Sql Server Express. I want to use Sql Server Compact.
What I did:
Created a new empty solution (not MVC template)
Installed sample project:
Install-Package Microsoft.AspNet.Identity.Samples -PreInstalled:
Install-Package Microsoft.SqlServer.CompactInstalled:
Install-Package EntityFramework.SqlServerCompactChanged default connection string in
web.configto:<add name="Foo" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\Foo.sdf;" />Changed
ApplicationDbContextto use theFooconnection string:ApplicationDbContext() : base("name=Foo", false)
Problem is, when ApplicationDbContext is accessed for the first time (during seeding, in the ApplicationDbInitializer.InitializeIdentityForEF() method):
- the database is created
- I get an
InvalidOperationException: UserId not foundfor the lineresult = userManager.SetLockoutEnabled(user.Id, false);
I thought it would be as simple as changing the connection string - so what am I doing wrong? Or put differently, how do I convert the solution from SQL Server Express to SQL Server Compact?