如何使用 Visual Studio 2019 for Mac 将区域添加到 ASP.NET MVC 项目?

问题描述 投票:0回答:3

我正在学习 Udemy ASP.NET Core 3 MVC 课程,并且我正在尝试向我的项目添加一个区域。据我所知,在 PC 上,此选项已移至“新脚手架项目”,其中显示“区域”选项,但在 Mac 上,此选项是“新脚手架”,而“区域”不是一个选项。

那么如何将新区域添加到我的 ASP.NET MVC 项目中? Google 未能返回专门针对 Mac 的任何内容。

c# asp.net-core asp.net-core-mvc visual-studio-mac
3个回答

0
投票

我了解您的需求。在 macOS 中,您没有像 Visual Studio for Windows 这样强大的工具。您需要使用命令行。

https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.1&tabs=netcore-cli

您将属于以下两种情况之一:是否具有现有的身份数据库架构。无论如何,您都可以使用命令行。使用这样的东西:

dotnet tool install -g dotnet-aspnet-codegenerator
dotnet aspnet-codegenerator identity --useDefaultUI
dotnet ef migrations add CreateIdentitySchema
dotnet ef database update
// ...

第一:安装工具通过

dotnet tool install -g dotnet-aspnet-codegenerator

第二个,用它

dotnet aspnet-codegenerator identity --useDefaultUI

其他技巧:您可以在PC(甚至远程Windows服务器)中创建一个新项目,生成您想要的所有内容,然后将其推送到Git服务器或在文件系统中手动复制这些文件。简单实用。


0
投票

将 Microsoft.VisualStudio.Web.CodeGeneration.Design 包添加到项目中作为 NuGet 包引用

安装/更新 dotnet-aspnet-codegenerator

dotnet 工具安装/更新 -g dotnet-aspnet-codegenerator

然后运行以下命令

dotnet aspnet 代码生成器区域

欲了解更多详情请点击以下链接

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-7.0

© www.soinside.com 2019 - 2024. All rights reserved.