2.2 KiB
The generated Identity database code requires Entity Framework Core Migrations. If a migration to create the Identity schema hasn't been created and applied to the database, create a migration and update the database. For example, run the following commands:
Visual Studio
In the Visual Studio Package Manager Console:
Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Add-Migration CreateIdentitySchema
Update-Database
.NET Core CLI
dotnet ef migrations add CreateIdentitySchema
dotnet ef database update
The "CreateIdentitySchema" name parameter for the Add-Migration
command is arbitrary. "CreateIdentitySchema"
describes the migration.
If the Identity schema has already been created but not applied to the database, only the command to update the database must be executed:
Visual Studio
In the Visual Studio Package Manager Console, execute Update-Database
:
Update-Database
.NET Core CLI
In a command shell, execute dotnet ef database update
:
dotnet ef database update
You can confirm the application of an Identity schema with the following command. The output of the command includes an "applied
" column to show which migrations are applied to the database.
Visual Studio
In the Visual Studio Package Manager Console, execute Get-Migration
:
Get-Migration
If more than one database context exists, specify the context with the -Context
parameter.
.NET Core CLI
In a command shell, execute dotnet ef migrations list
:
dotnet ef migrations list
If more than one database context exists, specify the context with the --context
parameter.