5

As I am unable to use the migrate.exe tool to update the database, I am creating migration SQL scripts, and applying them manually, which works perfectly.

As the seed part is not included into the migrations, they do not yield an SQL script.

How could I get the seed method to generate the SQL script?

I am currently applying the seed method to my local DB. One way to solve the problem would be to intercept the SQL calls with the entity framework interceptor, but that sound like a dirty hack. So is there a better way to do it?

  • Just because you cannot use `migrate.exe` doesn't mean you can't update the database, your DbContext can apply migrations at runtime. The `Seed` method often has complex or non-SQL logic, like comparisons or Id lookups, meaning that even if you did _record_ it through _SQL Profiler_, logs or with an interceptor it may not provide the right script to execute on another database. I don't use `migrate.exe` at all in my apps, the database is on the client so it was easier to just let EF do it for me at runtime. – Chris Schaller Aug 23 '20 at 05:10

0 Answers0