I am a bit dazzled; I am using dotnet core (2.1) EF with migrations. When I create the first migration just based upon the context, it all looks OK actually.
so I have a context like:
public class DataContext : IdentityDbContext<User, IdentityRole<Guid>, Guid>
{
public virtual DbSet<Country> Countries { get; set; }
public virtual DbSet<CountryUser> CountryUsers { get; set; }
//..more stuff
public DataContext(DbContextOptions options) : base(options)
{ }
}
so after creating the migrations it wants to add:
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable:
//etc. etc. Removed rest of migrations.
All good I thought.
Then i started to follow the following article; How to seed an Admin user in EF Core 2.1.0?
After setting the HasData
and seeding the DB, created a new migration, it created a new migration where it wanted to drop the AspNetRoles
table and creates as new table IdentityRole
.
I just deleted the DB and tried to do it again, and now it only wants to insert the data when seeding. But i cannot figure out what I changed and even better, why it wanted to drop and create different tables.
can somebody explain when it wants to create AspNetRoles
and when it wants to create IdentityRoles
(and along the other tables that goes with it).
Just to be sure; the context was always extending from
: IdentityDbContext<User, IdentityRole<Guid>, Guid>
and my User
:
public class User : IdentityUser<Guid>
{
public virtual ICollection<CountryUser> CountryUsers { get; set; }
}
thnx!!