Web API 2无法注册用户 [英] Web API 2 cannot register user
问题描述
我有一个使用MVC的Web API 2项目.它使用实体框架.该实体框架使用带有.edmx文件的数据库优先方法.
I have a Web API 2 project using MVC. It uses entity framework. This entity framework uses a database first approach with a .edmx file.
该项目基于VS 2013 Express Web API 2模板.我只是使用自己的数据库.我没有修改任何与帐户相关的代码.但是,当我尝试注册新用户时,AccountController.cs中的以下语句引发异常:
The project is based on VS 2013 Express Web API 2 template. I just used my own database. I didn't modify any account related code. But when I try to register a new user, the following statement in AccountController.cs throw exception:
public async Task<IHttpActionResult> Register(RegisterBindingModel model)
{
...
IdentityResult result = await UserManager.CreateAsync(user, model.Password);
...
}
该异常表明:
Cannot insert the value NULL into column 'Discriminator', table 'xxx.dbo.AspNetUsers'; column does not allow nulls. INSERT fails.
The statement has been terminated.
有人可以帮助我吗?谢谢!
Can anyone help me? Thank you!
推荐答案
我昨天升级了所有NuGet软件包.其中,Asp.net身份已升级到2.0.0.0.
I upgraded all NuGet Packages yesterday. Among them Asp.net Identity is upgraded to 2.0.0.0.
神奇地起作用.
所以我怀疑这是由于Identity 1.0中的某些错误
So I suspect that was because of some bug in Identity 1.0
这篇关于Web API 2无法注册用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!