ef code first - How can I avoid ASP.NET Identity from adding this extra field? -


I have a new MVC5 project with ASP.NET IDE 2.0 and EF 6.1.1.

I added our own ApplicationUser (based on the built-in IdentityUser) thus my DBContact is created.

  Public class ApplicationDbContext: IdentityDbContext & lt; ApplicationUser & gt; {Public ApplicationDbContext (): Base ("DefaultConnection", throwIfV1Schema: Incorrect) {} Create Public Static ApplicationDbContext () {Return New ApplicationDbContext}; }}   

When the database has been created I have tables like AspNetUsers, AspNetUserRoles, AspNetUserClaims, and AspNetUserLogins. .. IdentityUserLogin & gt; () HasKey & LT; String & gt; (L = & gt; Then I OnModelCreating () with very basic statement

  Protected Override Zero OnModelCreating (DbModelBuilder modelBuilder) {modelBuilder.Entity added & lt; l.UserId); Modlbilder Anti & lt; IdentityUserRole & gt; (). HasKey (r = & gt; new {r.RoleId, r.UserId}); }   

As soon as I add OnModelCreating (), the Identity Tables are automatically named ApplicationUsers, IdentityUserRoles, IdentityUserClaims, and IdentityUserLogins. This is the reason why I am fine (and I know how to change their name)

But what do not I like:. Suddenly, there was no such area in the original "ASPNATX" table, called "ApplicationUser_Id", all of an additional field of IdentityUserRoles, IdentityUserClaims, and IdentityUserLogins.

Why is that so? And can I do anything to avoid doing this?

You have to call on base. OnModelCreating . There are several additional things in it, which do OnModelCreating in IdentityDbContext , which you can disappear without calling - the default name of the tables is one of them.

First of all to call it first, then apply your own changes later.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -