Add-Migration CreateIdentitySchema

Dean Everhart 1,541 Reputation points
2023-02-02T19:03:35.49+00:00

Having difficulty with the Add-Migration CreateIdentitySchema step in the tutorial. Any help would be appreciated:

Tutorial: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=visual-studio#scaffold-identity-into-a-razor-project-with-authorization

Directions

PowerShellCopy

Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Add-Migration CreateIdentitySchema
Update-Database

First attempt

PM> add-migration CreateIdentitySchema

Build started...

Build succeeded.

More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.

There are two Context files:

projectname.data.ApplicationDbContext

projectname.areas.identity.data.WebApplication1Context

My assumption is that it is the second context file - in the areas.identity.data folder - that I'm targeting since the tutorial is authorization.

Second Attempt

PM> add-migration CreateIdentitySchema -Context Areas\Identity\Data\

Build started...

Build succeeded.

No DbContext named 'Areas\Identity\Data' was found.

PM> add-migration CreateIdentitySchema -Context Areas\Identity\Data\WebApplication1Context.cs

Build started...

Build succeeded.

No DbContext named 'Areas\Identity\Data\WebApplication1Context.cs' was found.

PM> add-migration CreateIdentitySchema -Context WebApplication1Context.cs

Build started...

Build succeeded.

No DbContext named 'WebApplication1Context.cs' was found.

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. SurferOnWww 4,631 Reputation points
    2023-02-03T00:53:01.0933333+00:00

    please try:

    add-migration CreateIdentitySchema -Context WebApplication1Context

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.