如何在 Visual Studio 2019 中为 mac 构建身份文件?
How to scaffold identity files in Visual Studio 2019 for mac?
我已将 AspNetCore.Identity 包含在我的 MVC 网络应用程序项目中,但是,模型和视图文件不会自动构建基架。在 Visual Studio for Windows 中,脚手架身份的选项通过 'Add > New Scaffolded Item' 在上下文菜单中。 Visual Studio 2019 Mac 中是否有类似的脚手架选项?
我找到了有关如何使用终端 here 构建身份文件的信息,但是,我的问题是 Visual Studio for Mac 是否在 UI 中具有此功能.
解决方案很少:
(1) 技巧:在 Windows 上使用 Visual Studio,然后搭建脚手架。然后复制到macOS电脑。方法很简单。
(2) 在 macOS 计算机上,安装工具
dotnet tool install -g dotnet-aspnet-codegenerator
然后生成脚手架文件
dotnet aspnet-codegenerator identity -h
从零开始。
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
删除这些:
Areas/Identity/Data
Areas/Identity/IdentityHostingStartup.cs
不需要电子邮件确认
在Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDefaultIdentity<IdentityUser>(options => {
options.SignIn.RequireConfirmedAccount = false;
}
).AddEntityFrameworkStores<ApplicationDbContext>();
}
我已将 AspNetCore.Identity 包含在我的 MVC 网络应用程序项目中,但是,模型和视图文件不会自动构建基架。在 Visual Studio for Windows 中,脚手架身份的选项通过 'Add > New Scaffolded Item' 在上下文菜单中。 Visual Studio 2019 Mac 中是否有类似的脚手架选项?
我找到了有关如何使用终端 here 构建身份文件的信息,但是,我的问题是 Visual Studio for Mac 是否在 UI 中具有此功能.
解决方案很少:
(1) 技巧:在 Windows 上使用 Visual Studio,然后搭建脚手架。然后复制到macOS电脑。方法很简单。
(2) 在 macOS 计算机上,安装工具
dotnet tool install -g dotnet-aspnet-codegenerator
然后生成脚手架文件
dotnet aspnet-codegenerator identity -h
从零开始。
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
删除这些:
Areas/Identity/Data
Areas/Identity/IdentityHostingStartup.cs
不需要电子邮件确认
在Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDefaultIdentity<IdentityUser>(options => {
options.SignIn.RequireConfirmedAccount = false;
}
).AddEntityFrameworkStores<ApplicationDbContext>();
}