My seed data uses the HasData method for insert:
modelBuilder.Entity<SystemResource>().HasData(new[]
{
new SystemResource()
{
Id = 1,
Code = "roi-dev-003",
IsEnabled = true,
}
});
I would like to change the value of the Code property of generated seed data to a new value. Can it be done using seed data or is an sql update of DB needed?
The signature of the HasData method says it is used to generate data motion migration. How does a data motion migration work?
Update:
Changing the value of Code property and then running update-database has no effect:
PM> update-database
No migrations were applied. The database is already up to date.
Unfortunately, it doesn't appear that this functionality is supported in EFCore currently.
This article is a pretty in-depth overview of the HasData system. This line from it is relevant:
But HasData isn’t a silver bullet. Keep in mind that this feature is best for seed data that will remain static once it’s been inserted into the database.
I too have been looking for a good solution to this problem
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