我尝试了一个新的 Blazor Server 项目,它适用于:
- 指定至少一个覆盖(我选择了Login、Logout和Registration)
- 指定 _Layout.cshtml 的完整路径(我使用过/Areas/Identity/Pages/Account/Manage/_Layout.cshtml)
- 添加上下文
- 添加用户模型
然后脚手架按预期工作。
我得到以下结构:
![在此处输入图像描述](https://i.stack.imgur.com/8D0LG.png)
脚手架生成的用户模型类将是:
namespace Test2.Areas.Identity.Data
{
// Add profile data for application users by adding properties to the Test2User class
public class Test2User : IdentityUser
{
}
}
更新
我在 Visual Studio 生成器中发现了一个错误。
从现有项目中搭建身份页面的唯一可能性是通过命令行执行搭建过程。
下面是一个命令行示例:
dotnet aspnet-codegenerator identity -dc TestWasmAuthIndividual.Server.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout;Account.Manage.PersonalData" --force
您需要从服务器项目执行此命令行。