5

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.

Vy Do
  • 46,709
  • 59
  • 215
  • 313
stalemate
  • 67
  • 1
  • 7
  • From the latest notes of [Visual Studio 2019 for Mac version 8.4](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-for-mac-version-8-4-is-now-available/#scaffolding) we can see, you can only add `New Scaffolding… ` with common entity. It will be added in the near future. – Michael Wang Sep 10 '20 at 07:40
  • 1
    This is not currently supported. The identity scaffolder had some problems/missing pieces in Visual Studio for Mac so it was removed. The plan is for it be included in the future - but I do not have a specific release where this will happen. – Matt Ward Sep 16 '20 at 19:56
  • Thanks Matt, this answers my question. – stalemate Sep 16 '20 at 21:59

2 Answers2

3

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

Vy Do
  • 46,709
  • 59
  • 215
  • 313
0

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>();
}
Omar Magdy
  • 2,331
  • 14
  • 13