❔ Need help with EF 6 Migrations
Hello all,
I have recently inherited a project that has entity framework Core 6 Code first approach. The initial migration had an up method that created a trigger by executing it as sql. Meaning, there is a variable that contains sql syntax and EF is just executing it in the backend.
Now i need to update that sql script. How do i go about updating it and creating a new migration? should i just create a migration (which will be empty) and write the modified trigger into a variable and execute it? or is there a more streamlined way of doing this?
Thanks!
6 Replies
Assuming this is for a database which is pre-existing you should be making a new migration and writing the sql command to alter the trigger inside Up method
okay, so basically writing the alter method manually in UP is the way to go is it?
Yes that's right
Just alter the trigger with sql server management studio if you don’t care about your migration history
EF has nothing to do with triggers, it only needs to know if a table has a trigger so that it will use the old, less efficient, technique for querying which is compatible with tables with triggers
EF Core will use a more efficient technique for tables without triggers
If this is a shared project it may be useful to alter the trigger within a migration so other team members will have it.
Great. Good info. Thanks guys.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.