1

I am using MVC 5 and sql server 2012.I have created DB with name TestDB its doest not contain any table.Now i am trying to use Identity which is default given in AccountController in MVC project. I have change in AccountController "Defaultconnection" to my TestDBEntities connection but i am getting error System.InvalidOperationException: The entity type ApplicationUser is not part of the model for the current context. How i can created Identity with exist Database.

  <connectionStrings>
  <add name="TestDBEntities" connectionString="metadata=res://*/DAL.TestModel1.csdl|res://*/DAL.TestModel1.ssdl|res://*/DAL.TestModel1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=xxxxx;initial catalog=TestDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

  public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{

    public ApplicationDbContext()
        : base("TestDBEntities", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}
kitty sarvaj
  • 517
  • 5
  • 10
  • 24

1 Answers1

0

As per my understanding, the possible ways to solve your problem is:

1.Cross check that have you added the ApplicationDbContext to the UserStore constructor

Ex: https://stackoverflow.com/a/23894335/3397630

2.Also check that do you have any other connection string in the webconfig file. This may also cause the problem.

Finally if both above points doesn’t work, kindly follow the below article:

http://www.codeguru.com/csharp/.net/net_asp/mvc/securing-asp.net-mvc-applications-with-asp.net-identity.htm

It was really good, I personally used and created a identity tables for my projects without any issues.

In the articles, it was explained each , every points very well and easy understandable.

Hope the above information will be useful , kindly let me know your thoughts or feedbacks

Thanks

Karthik

Karthik Elumalai
  • 1,574
  • 1
  • 11
  • 12