Now I am much more familiar with this.
The easiest way to get this to work, either first with code or with a database, is to modify the existing database so that it has at least the minimum database schema (tables, columns and foreign keys) that the ASP.NET Identity Framework uses.
You can see the minimal circuit in the image below:

Although it does not have column types, it is still useful to see it. You can get the exact schema from the SQL database database template specified on this page .
I am sure that you can avoid the need to bind the existing database to this scheme by creating some kind of mappings either inside your code (code first) or using the EF tools (database first) to map from the column name to another name inside your code ... but I have not tried it.
I created most of the tables from scratch, except for the User table, where I changed the original Username column to Username (case correction) to map and add additional columns that do not already exist.
First code
Once you have the database in place and you know that the schema is correct, you might want to use the reverse-engineer code first function for Visual Studio to raise your EF classes for you. This way, your new EF classes will exactly match your table layouts. Otherwise, you will have to code-copy all your models with all the mappings.
Once you have the EF classes, you must inherit them from different classes from the Identity Framework. Since you do this first as code, you can add inheritance to EF classes without fear that they will be overwritten (as opposed to a database).
public class User : IdentityUser<int, UserLogin, UserRole, UserClaim> { // Any additional columns from your existing users table will appear here. } public class Role : IdentityRole<int, UserRole> { } public class UserClaim : IdentityUserClaim<int> { } public class UserLogin : IdentityUserLogin<int> { } public class UserRole : IdentityUserRole<int> { }
Note the int specified in each, this indicates the type of the primary key of the user table. This is the default string, but my Id value in my existing database is an int that automatically increments.
Database first
When you use the EF database, firstly, you donβt have the luxury of adding the inheritance of Identity Framework classes directly to automatically generated classes. This is because they are overwritten every time you make changes to the model using the Visual Studio Entity Framework tools.
However, the created classes are automatically generated - these are all partial classes, so this can be achieved by creating a new file with the definition of partial classes that will not be overwritten. They must be in the same namespace and exactly the same name.
So, for example, it could be a class generated by EF:
namespace Dal { public partial class User {
And this is the model we can create to add our inheritance:
// same namespace as existing class namespace Dal { // Same name as existing class public partial class User : IdentityUser<int, UserLogin, UserRole, UserClaim> { // This can probably be left blank } }
So, you would do this for each of the classes required for the ASP.NET Identity Framework:
public partial class User : IdentityUser<int, UserLogin, UserRole, UserClaim> { // Any additional columns from your existing users table will appear here. } public partial class Role : IdentityRole<int, UserRole> { } public partial class UserClaim : IdentityUserClaim<int> { } public partial class UserLogin : IdentityUserLogin<int> { } public partial class UserRole : IdentityUserRole<int> { }