Reputation: 77
I have included AspNetCore.Identity in my MVC web app project however, the model and view files do not scaffold automatically. In Visual Studio for Windows the option to scaffold identity is in the context menu via 'Add > New Scaffolded Item'. Is there a similar scaffolding option in Visual Studio 2019 for Mac?
I have found info on how to scaffold identity files using terminal here however, my question is about if Visual Studio for Mac has this ability in the UI.
Upvotes: 6
Views: 6246
Reputation: 3303
From Scratch.
dotnet new webapp --output "WebApp1" --name "WebApp1" --auth Individual
cd WebApp1
dotnet dev-certs https --trust
dotnet tool install -g dotnet-aspnet-codegenerator
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
dotnet add package Microsoft.AspNetCore.Identity.UI
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
dotnet tool install --global dotnet-ef
dotnet aspnet-codegenerator identity
Delete these:
Areas/Identity/Data
Areas/Identity/IdentityHostingStartup.cs
Not Requiring email Confirmation
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDefaultIdentity<IdentityUser>(options => {
options.SignIn.RequireConfirmedAccount = false;
}
).AddEntityFrameworkStores<ApplicationDbContext>();
}
Upvotes: 0
Reputation: 52576
There are few solutions:
(1) trick: Use Visual Studio on Windows, then scaffolding. Then copy to macOS computer. It's easy way.
(2) On macOS computer, Install tool
dotnet tool install -g dotnet-aspnet-codegenerator
then generate scaffoloding files
dotnet aspnet-codegenerator identity -h
Reference document: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.1&tabs=netcore-cli#scaffold-identity-into-an-empty-project
Upvotes: 4