I don't have any idea why it happens. I have DbContext which inherits from IdentityDbContext:
public class TestContext : IdentityDbContext<ApplicationUser>
{
public TestContext()
: base("name=DomainModelContainer")
{
}
// protected override void OnModelCreating(DbModelBuilder modelBuilder)
// {
// throw new UnintentionalCodeFirstException();
// }
public virtual DbSet<AspNetRole> AspNetRoles { get; set; }
public virtual DbSet<AspNetUserClaim> AspNetUserClaims { get; set; }
public virtual DbSet<AspNetUserLogin> AspNetUserLogins { get; set; }
public virtual DbSet<AspNetUser> AspNetUsers { get; set; }
public virtual DbSet<Blog> Blogs { get; set; }
public virtual DbSet<Category> Categories { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<IdentityUserLogin>().HasKey<string>(l => l.UserId);
modelBuilder.Entity<AspNetUserLogin>().HasKey<string>(l => l.UserId);
modelBuilder.Entity<IdentityRole>().HasKey<string>(r => r.Id);
modelBuilder.Entity<IdentityUserRole>().HasKey(r => new { r.RoleId, r.UserId });
base.OnModelCreating(modelBuilder);
//modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
So when I try to execute simple code. Something like
var testContext = new TestContext();
testContext.AspNetRoles.Count();
I get an exception Invalid object name 'dbo.AspNetRoles1'
Why EF decides to add "1" to table name? What is the point?