【发布时间】:2018-02-07 09:13:36
【问题描述】:
在我按照this 将应用程序用户 ID 的类型从字符串更改为 int 后,如果我尝试创建新用户,则会收到 SqlException。
确切的错误是:
无法将值 NULL 插入到列“Id”表“DBNAME.dbo.AspNetUsers”中;列不允许空值。插入失败。声明已终止。
Line 208: };
Line 209:
Line 210: var result = await UserManager.CreateAsync(user, model.Password);
Line 211: if (result.Succeeded)
Line 212: {
Source File: C:\Projects\ProjectName\ProjectName\Controllers\MembersController.cs Line: 210
[SqlException (0x80131904): Cannot insert the value NULL into column 'Id', table 'DBNAME.dbo.AspNetUsers'; column does not allow nulls. INSERT fails.
The statement has been terminated.]
我看过How to tell the primary key 'Id' of IdentityUser class is IDENTITY(1,1)? 和ASP.NET Identity - Error when changing User ID Primary Key default type from string to int AND when using custom table names 但对我帮助不大。
非常感谢任何帮助。
【问题讨论】:
标签: asp.net entity-framework asp.net-identity