I'm trying to follow a tutorial to add a migration(a second one) generated from IdentityDbContext
and IdentityUser
.
When I run dotnet ef migration add <NAME>
it being add, but UP
and DOWN
are empty.
I found that deleting the data from EFMigrationHistory table can solve the problem, but the table doesn't contain any information about that migration, only on the first one that was already created. I tried deleting all the .TMP files, drop and recreate the migration .
WorldUser :
namespace TheWorld.Models
{
public class WorldUser : IdentityUser
{
public DateTime FirstTrip { get; set; }
}
}
WorldContext :
namespace TheWorld.Models
{
public class WorldContext : IdentityDbContext<WorldUser>
{
private IConfigurationRoot _config;
public WorldContext(IConfigurationRoot config,DbContextOptions options) : base(options)
{
_config = config;
}
....
The weird thing is, it didn't work yesterday, and today morning I tried deleting all the .TMP files, the migrations, and recreate it via the CMD, and it generated a migration that looked correct, but stupidly, I deleted it because it had the wrong name, and since recreated it doesn't work again .
Your migrations folder should contain a WorldContextModelSnapshot.cs
, this file contains a definition for the entire database. If the model is already defined in this file, it will no longer appear in new migrations.
If you want to generate the migration again, remove the model from this file and generate your migration again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With