I have an IdentityDbContext in my data layer but I can't use and packages form Microsoft.AspNetCore. I need to decouple it form the data layer so I can reuse the database context without Identity in a different domain service.
IdentityDbContext is inside Microsoft.AspNetCore
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace DataLayer.Data
{
public class MyDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<Table1> Table1 { get; set; }
public DbSet<Table2> Table2 { get; set; }
public MyDbContext(DbContextOptions<MyDbContext> options)
: base(options) { }
}
}
I want to achieve something like this where I have Dbcontext in my data layer and later in my web layer I can configure Identity
using Microsoft.EntityFrameworkCore;
namespace DataLayer.Data
{
public class MyDbContext : DbContext
{
public DbSet<Table1> Table1 { get; set; }
public DbSet<Table2> Table2 { get; set; }
public MyDbContext(DbContextOptions<MyDbContext> options)
: base(options) { }
}
}
I had a look at this post but it is about asp.net
Decoupling ASP.NET MVC 5 Identity to allow implementing a layered application
Is it possible to do this in asp.net core, if yes HOW?
Microsoft.AspNet.Identity.EntityFrameworkin data layer which does not answer my question. I want to know if I can decouple identity from data layer & if not I need a concert reasoning, as it makes the data layer restricted for MVC applications which are using Identity, thus reducing reusability.