- EF Core Version 3.1.4.
- SQL Server 2014.
How do I get EF core to re-seed data after it has been deleted out of the database? It's deleted directly in the database, not through an EF core migration.
My latest migration file has this:
migrationBuilder.InsertData(
table: "Person",
columns: new[] { "ID", "Name" },
values: new object[]
{
{ 1, "Tom Watson" }
});
After running Update-Database the Person with ID 1 is created, then someone runs delete from Person in SQL Server. At this point I want to re-seed the data. Running Update-Database does not insert the Person back into the database.
My current solution is to remove my modelBuilder.Entity<Person>().HasData(...) code, create a new migration, then add that code back in and create another migration and then finally Update-Database. This is an ugly solution that creates unwanted migrations.
Any ideas? Obviously I can just do an insert on the database, but I'd like to do this through the EF package manager console, as I have a lot more seed data than just this one record.