【发布时间】:2018-04-26 14:27:27
【问题描述】:
这可能很容易,但我是新手,无法在线找到解决方案。 在 .net core 2.0 身份验证中,用户表使用 ID 作为主键的列名。我想将其更改为 UserID,但我不知道该怎么做。 我已将数据库和自定义 IdentityUser 类中的列更改为 UserID,但现在当我创建新记录时出现错误消息
SqlException:列名“Id”无效。
【问题讨论】:
标签: authentication asp.net-core-2.0
这可能很容易,但我是新手,无法在线找到解决方案。 在 .net core 2.0 身份验证中,用户表使用 ID 作为主键的列名。我想将其更改为 UserID,但我不知道该怎么做。 我已将数据库和自定义 IdentityUser 类中的列更改为 UserID,但现在当我创建新记录时出现错误消息
SqlException:列名“Id”无效。
【问题讨论】:
标签: authentication asp.net-core-2.0
我设法找到了答案:-
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Domain.Models.Member>().Property(up => up.Id).HasColumnName("UserId");
}
【讨论】: