First off, entities never have a reference to EF. They're just classes. Your DbContext
subclass is what stitches them into Entity Framework. Second, ApplicationUser
is your user. It's not part of Entity Framework; it's merely a class that inherits from the EF model IdentityUser
. If that's your problem, then you kind of just need to get over it. You can't entirely abstract away Entity Framework, unless you just stop using Entity Framework. Otherwise, there will always be a reference somewhere.
So, to just combine the two contexts so you can work with ApplicationUser
within your other entities, you merely just need to change the class your application's context inherits from, from DbContext
to IdentityDbContext<ApplicationUser>
. Then, you can just delete the class that MVC generated for you, after of course switching the reference to your application's context in AccountsController
. Again, there's no problem here inheriting from IdentityDbContext
because the context is inherently tied to Entity Framework, anyways.