I need to unbind Identity from my Asp.net core MVC layer and throw it to another crosscutting layer of my DDD project. Based on Eduardo Pires' Equinox project, I managed to do it, but I'm finding it difficult to activate Migrations. For you to understand what I did:
1 - I created the SystemComercial.Presentation.Web.MVC layer with user authentication. Automatically, the system has created several folders, controllers, and classes necessary for authentication to work, including the local database. Fantastic !!!!
2-IcreatedaSystemComercial.Infra.CrossCutting.Identity.Datalayerandmanually,Icreatedthesamefolders,controllersandclassesofthemvclayer.TheideaistoactivateMigrationsonthislayerandthenIremoveeverythingfromtheMVClayerandinthisway,theoperationwouldbedecoupledandontheIdentitylayer.
WhenItrytorun"Add-Migration InitialCreate -Context: ApplicationDbContext", the following error message appears:
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager [0] User profile is available. Using 'C: * \ Local \ ASP.NET \ DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. More than one DbContext named 'ApplicationDbContext' was found. Specify which one to use by providing its fully qualified name using its exact case.
//Minha classe de contexto na camada Identity
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// get the configuration from the app settings
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
// define the database to use
optionsBuilder.UseNpgsql(config.GetConnectionString("DefaultConnectionpg"));
}
}
Does anyone know how to help me to activate Migrations in the created Identity layer?
Project link: link