The entity type ApplicationUser is not part of the model for the current context
for me it seems to miss a context instanciation:
UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());
should be
UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
I was having this same problem. I’m doing database first development with an EDMX file.
If you are using the connection string generated when adding the EDMX file in :base(“EDMXConnString”)
you will most likely have this problem.
I fixed this by creating a standard connection string that pointed to the database where the ASP.NET Identity tables are.
<add name="MyConnString" connectionString="Data Source=server; Initial Catalog=db_name; User ID=user_id; Password=password; Connect Timeout=60;" providerName="System.Data.SqlClient" />
And then used that connection string in :base
, and it worked!
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("MyConnString")
{
}
}
My problem was I tried to use generated ADO.NET connection string for both generated and authentication context ApplicationDbContext
. I fixed it by using a separate connection string for authentication. Also pay attention to the provider - for authentication context it has to be System.Data.SqlClient
:
<add name="DefaultConnection" connectionString="Server=qadb.myserver.com;Database=mydb;User Id=myuser;Password=mypass;" providerName="System.Data.SqlClient" />