Am I able to use Entity Framework models (Classes) as a classes for Identity

so the relations that I have in my database will be loaded when I retrieve the user and if I update any columns or add tables I only have to deal with Entity Framework model.

I did do my custom classes for users

public class MyUser : IdentityUser<long, MyLogin, MyUserRole, MyClaim>{ ... }

and connected it with the table

 protected override void OnModelCreating(DbModelBuilder modelBuilder)

but I have more tables that are connected with 'Users' table that isn't with Identity model for example:

I have a table called Person(Not really just an example)

and each person may have many users and each user may have many persons

So We have another table called 'PersonsUsers'

So the user have a list

I don't want to call the database twice to retrieve a single user data, and mapping the table from code will make my code static and depends on me updating the source code.

so Is it possible to use the classes that EF generated for the tables?

Do you have any other solution?

many thanks in advance.

Related posts

Recent Viewed