asp.net web api2 - Web API 2 cannot register user -
i have web api 2 project using mvc. uses entity framework. entity framework uses database first approach .edmx file.
the project based on vs 2013 express web api 2 template. used own database. didn't modify account related code. when try register new user, following statement in accountcontroller.cs throw exception:
public async task<ihttpactionresult> register(registerbindingmodel model) { ... identityresult result = await usermanager.createasync(user, model.password); ... }
the exception says:
cannot insert value null column 'discriminator', table 'xxx.dbo.aspnetusers'; column not allow nulls. insert fails. statement has been terminated.
can me? thank you!
the answer in question's body.
table 'xxx.dbo.aspnetusers'; column not allow nulls.
seems be, you're trying insert null
value model instance registerbindingmodel model
, structure of table in database server doesn't allow accept null
value.
try debug , check, model instance creating correctly when request coming.
also can see, use:
identityresult result = await usermanager.createasync(user, model.password);
why user isn't member of model, password property? maybe try use:
identityresult result = await usermanager.createasync(model.user, model.password);
anyway... don't have more info , don't imagine, inside model instance, how you're binding data in request. should in debugger , debug repair project or provide more info.
but 1 thing clear crystal, you're trying insert null
value column, doesn't accept null
, must check how model binding. maybe client-side application doesn't send correctly arguments, maybe you're binding model incorrectly, maybe else... there need more information you, otherwise should debug carefully.
Comments
Post a Comment