I use Entity Framework Migrations for code first to control my database model. It works charming and I can handle until now everything. But now I need to add one database tr
You can just add a Sql("SQL COMMAND HERE") method call to your migration's Up
method. Don't forget to also add the drop statement to the Down
method. You can create an empty migration if you need, just by running Add-Migration
without any changes to the model.
public partial class Example : DbMigration
{
public override void Up()
{
Sql("CREATE OR REPLACE TRIGGER [name] BEFORE UPDATE ON myTable ...");
}
public override void Down()
{
Sql("DROP TRIGGER [name]");
}
}