Entity Framework 6, MVC5, ASP Identity 2.0.
I am new to Entity infrastructure and ASP Identity. I created the database using the Code First approach, following the instructions below: http://dotnetcodr.com/2014/07/10/introduction-to-entityframework-6-part-1-the-basics-of-code-first/ and applying them accordingly to my own project.
The tables were created, everything is fine. But when I try to register a new user, an exception occurs: "Entity Framework 6, ASP Identity. Cannot insert NULL value in the column" Discriminator ", table" ... AspNetUsers ", the column does not allow zeros. INSERT cannot." Launched by CreateAsync method in AccountController
Line 153: {
Line 154: var user = new ApplicationUser {UserName = model.Email, Email = model.Email};
Line 155: var result = wait UserManager.CreateAsync (user, model.Password);
Line 156: if (result.Succeeded)
Line 157: {
I'm not even sure which part of the code I should insert here.
Here is my DbContext:
public class BulkMailerContext : IdentityDbContext<ApplicationUser> { public BulkMailerContext() : base("BulkMailerContext", throwIfV1Schema: false) { } public DbSet<Email> Emails { get; set; } public DbSet<SubscriptionList> SubscriptionLists { get; set; } public DbSet<Recipient> Recipients { get; set; } }
And here the default Identity context is used:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("BulkMailerContext", throwIfV1Schema: false) { } public static ApplicationDbContext Create() { return new ApplicationDbContext(); } }
I did not find much information about this exception.
This post http://forums.asp.net/t/1974183.aspx?Cannot+insert+the+value+NULL+into+column+Discriminator assumes that the project has a class that inherits from the user. I have nothing of the kind.
This post is https://connect.microsoft.com/VisualStudio/feedback/details/800655/calling-new-user-with-4-5-1-does-not-pass-column-discriminator-required-in-aspnetusers- tables about the web API project, and the Microsoft team said that this is a mistake, and they will fix it, as I understand it.
This Cannot insert a NULL value in the AspNetUsers "Discriminator" column . offers no solution
This Web API 2 cannot register a user, assumes that this is fixed in Identity 2.0, but I have Identity 2.0 currently
I have automatic migration - disabled if that matters. But I updated db manually from the PM console using the update-database command.
Any suggestions are welcome.