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.