You can add scripts to code first migration.
First, make sure if any existing migration is pending. If so,
-open the package manager console window.
-Select the appropriate project
-Run “update-database” command (without quote)
Now, add the migration you want to put SQL into.
-Run “Add-Migration SQLIntoMigration” (without quote)
A new MIgration file will be added with an empty body like this:
1 2 3 4 5 6 7 |
public override void Up() { } public override void Down() { } |
Now add the below code inside up() method.
1 |
SQL(@"Select * FROM TEMP"); |