我需要创建一个具有用户名、名字、姓氏和电子邮件字段的用户。我正在使用 Mysql 数据库和 Pomelo 包。迁移和数据库更新工作正常。
此代码会导致失败。
public async Task<IActionResult> CreateUserAsync()
{
var user = new ApplicationUser(
UserName: "blablabla",
FirstName: "blablabla",
LastName: "blablabla",
Email: "[email protected]"
);
var successful = await mUserManager.CreateAsync(user
, "Pasword123456#");
if(successful.Succeeded)
return Content("User was created", "text/html");
return Content("User created FAILED", "text/html");
}
}
数据库中的表为空
+------------------------+ |日历中的表格 |
+------------------------+ | __efmigrationhistory | __efmigrationhistory | | aspnetrole 声明 | |阿斯普尼鲁斯 | | aspnet 用户声明 | |
aspnet 用户登录 | | aspnet 用户角色 | | ASP网络用户
| | aspnet 用户令牌 | |活动 | |乌苏阿里奥
|
+------------------------+
mysql> 从 aspnetusers 选择*;
空集(0.00 秒)
我不知道如何让它发挥作用。
In debug mode that is the only information I have.
我发现了问题所在。
I was overwriting Email and UserName in ApplicationUser.
This was the warning in the building.
解决方案只是删除这些字段。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)