gpt4 book ai didi

asp.net - SqlException : Invalid column name 'NormalizedName' . 无效的列名 'ConcurrencyStamp'。无效的列名 'NormalizedName'

转载 作者:行者123 更新时间:2023-12-04 09:05:39 36 4
gpt4 key购买 nike

为什么在 .NET Core Identity 上使用 PasswordSignInAsync 时出现异常? Microsoft.AspNetCore.Identity

await _signInManager.PasswordSignInAsync(user.UserName, Input.Password, Input.RememberMe, lockoutOnFailure: false);

An unhandled exception occurred while processing the request.
SqlException: Invalid column name 'NormalizedName'.
Invalid column name 'ConcurrencyStamp'.
Invalid column name 'NormalizedName'.
Microsoft.Data.SqlClient.SqlCommand+<>c.<ExecuteDbDataReaderAsync>b__164_0(Task<SqlDataReader> result)

我可以创建用户、重置密码等等。 “NormalizedName”甚至不是 Microsoft.AspNetCore.Identity 的一部分。我的表中存在所有列

select LockoutEnd, TwoFactorEnabled, PhoneNumberConfirmed, PhoneNumber, ConcurrencyStamp, SecurityStamp, 
PasswordHash, EmailConfirmed, NormalizedEmail, Email, NormalizedUserName, UserName, Id, LockoutEnabled, AccessFailedCount
from [dbo].[AspNetUsers]

最佳答案

异常实际上来自 AspNetRoles 表,而不是 AspNetUsers 表。如果您已将旧的 Asp.Net Identity 迁移到 Asp.Net Core,则需要将两个新字段添加到 Roles 表中。这是一个迁移:

public partial class Identity : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "NormalizedName",
table: "AspNetRoles",
type: "nvarchar(256)",
maxLength: 256,
nullable: true);

migrationBuilder.AddColumn<string>(
name: "ConcurrencyStamp",
table: "AspNetRoles",
type: "nvarchar(max)",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ConcurrencyStamp",
table: "AspNetRoles");

migrationBuilder.DropColumn(
name: "NormalizedName",
table: "AspNetRoles");
}
}

如果您想要完整的Identity 迁移,包括用户、声明和其他表,您可以引用我对这个问题的回答:https://stackoverflow.com/a/65003440/1348324

关于asp.net - SqlException : Invalid column name 'NormalizedName' . 无效的列名 'ConcurrencyStamp'。无效的列名 'NormalizedName',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63456536/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com