Re: throw exception when insert data with entityframeworkcore
Posted by: Carson Howard
Date: September 11, 2016 04:38PM

I also am having this issue when trying to use Microsoft.AspNetCore.Identity. Here is my DbContext

public partial class ApplicationDbContext : IdentityDbContext<User, IdentityRole<int>, int>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
:base(options)
{

}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}

And here is my User class

public class User : IdentityUser<int>
{
public string CustomerId { get; set; }
}

I am trying to use EnsureCreated to generate the DB tables.

using (var ctx = app.ApplicationServices.GetService<ApplicationDbContext>())
{
ctx.Database.EnsureCreated();
}

Then I get the same error as George.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.