Search code examples
asp.net-core-mvcasp.net-identityvisual-studio-mac

How to scaffold identity files in Visual Studio 2019 for mac?


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.


Solution

  • 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