Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to create a new user when receiving a POST request to api/accounts/ in my asp.net web-api 2 project.

Attempt 1: Create Identity User

I've tried exactly as it was shown in the project template:

// Inside Post() method
IdentityUser newUser = new IdentityUser()
{
    UserName = "username",
};
IdentityResult result = await this.UserManager.CreateAsync(newUser, "password");

System.Data.Entity.Core.UpdateException: Cannot insert the value NULL into column 'Discriminator', table 'MyDb.dbo.AspNetUsers'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated.

Attempt 2: Create a User

I've also tried adding my subclassed version of IdentityUser:

// Definition
public class User : IdentityUser
{
    public User() { }
}

// Inside Post() method
User newUser = new User()
{
    UserName = userDto.Email,
};
IdentityResult result = await this.UserManager.CreateAsync(newUser, "password");

System.InvalidOperationException: Mapping and metadata information could not be found for EntityType 'MyProject.Data.User'.

It was working originally and I can't figure out why it isn't anymore. Originally I added two fields onto my User object (FirstName, Lastname) but I still have the problem after removing them.

share|improve this question
    
+1 I've run into a similar problem, and posted my own question regarding this. I'll be monitoring this thread. stackoverflow.com/questions/21661018/… –  Goran_Mandic Feb 11 at 8:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.