In relation to this question: MVC 5 Seed Users and Roles I tried to set up a default user seed. The way I tried it in the Configuration.cs was:
var passwordHash = new PasswordHasher();
string defaultPassword = passwordHash.HashPassword("SuperPassword");
context.Users.AddOrUpdate(u => u.UserName,
new ApplicationUser
{
UserName = "admin@project.loc",
Email = "admin@project.loc",
PasswordHash = defaultPassword
});
But now I have the problem that I can't use the commands to migrate the database. Solutions that worked for other people unfortuantely didn't help me.
When I try to update-database I'm getting the error:
There is already an object named 'AspNetRoles' in the database.
I tried to use Add-Migration <name> -IgnoreChanges
but got the error, that migrations are still pending.
Earlier I tried to enable-migrations for my both contexts but for one I got this error message:
Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel.
Enable-Migration for the other context just overwrote my Configuration.cs with the customized seed.