0

ASP Web API has individual user accounts. It's great! But I don't get how to add custom fields to user. I followed the steps shown here How to extend asp.net web api 2 user? but I always get internal server error, which turned out to be Entity error. It compiles just fine and works, but won't make any records in db if I send requests to it. The 'untouchedd' version works fine, Any suggestions?
The Source code looks like this - I've added a new class for user.

public class AppUser : IdentityUser<br>
{
   public string Email { get; set; }<br>
}

Then replaced every IdentytUser with my App user, added Email to model and db.
And finally modified a controller.

AppUser user = new AppUser<br>
{
    UserName = model.UserName,<br>
    Email = model.Email<br>
}


IdentityResult result = await UserManager.CreateAsync(user, model.Password); 
IHttpActionResult errorResult = GetErrorResult(result); 

It stops working on the last line.

Community
  • 1
  • 1
Frosty
  • 65
  • 1
  • 10
  • 2
    Show us your code, and specify the line of code on which you are getting the error (you can find that out by examining the stack trace). – Robert Harvey Feb 18 '14 at 03:19
  • just as sec, new to stackoverflow – Frosty Feb 18 '14 at 03:30
  • It would help if you could include the full context of the code (at least the entire controller) as well as include the actual error message (without the full stack trace) being generated in the debugger session. – David Antaramian Feb 18 '14 at 05:21
  • Also, please include the class definition for your database context. – David Antaramian Feb 18 '14 at 05:23
  • Made it work by adding Discriminator field. Is it possible to make it through without it? – Frosty Feb 18 '14 at 11:20
  • ASP.NET Identity adds a `Discriminator` column to its database table automatically to handle extensions of the `IdentityUser` class. You should not be adding one manually. Please add the code requested in my previous two comments so that we can see what you are doing. – David Antaramian Feb 18 '14 at 23:08

0 Answers0