I am implementing ASP.NET Core Identity in an existing project with an existing Database.
I have specified the Entities to use for IdentityUser
and IdentityRole
like this:
public partial class MyContext : IdentityDbContext<MyUser, MyRole, int>
In Startup.cs
:
services.AddIdentity<MyUser, MyRole>(options =>
{
options.User.RequireUniqueEmail = true;
}).AddEntityFrameworkStores<MyContext>();
I was able to apply the migrations successfully to the database. But, on inspecting the AspNetRole table, I could see that EF created some extra columns.
How do I tell EF Core to use the existing colums (like RoleId
for Id
in the above image) instead of creating new ones?
Also, I noticed that EF Core changed MyRoles
table name to AspNetRoles
which was not the case with the MyUsers
table. MyUsers
table name remained the same even though extra columns were created as I mentioned above. Why is that?
PS: I am using DotNet Core 3.0 with EF Core 3.0.