Search code examples
sql-serverentity-framework-coreasp.net-identityidentityserver4asp.net-core-3.1

Create Identity (Membership) database with a different db-schema


In my asp net core 3.1-project, Im trying out MS Identity, by adding Authentication when I create a new template (Asp net core 3.1+react)

I was hoping to add my Identity tables to a different schema, using this simple Guide, ie

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    modelBuilder.HasDefaultSchema("notdbo");
}

But when I run "Update database" in package manager, it still creates a database in dbo-schema


Solution

  • You need to add a valid migration first, before you do the Update-Database. The catch is that there is already one migration pending in the code, so that's why your change will not be detected.