Reputation: 5970
When i run migrations to create a database via the Package Manager Console. Is there a way to output text from the Seed method to the NuGet console?
Just the simple create command:
Update-Database -StartupProjectName "Data" -Verbose
Upvotes: 8
Views: 2731
Reputation: 106
You can execute an SQL PRINT command within the Up()
or Down()
methods of each individual migration.
base.Sql("PRINT 'I heart kittens';");
This will output 'I heart kittens' to the Package Manager Console window in highlighted yellow text during the 'update-database' process.
Upvotes: 7
Reputation: 469
The command
Update-Database -Verbose
print in your console the sql code for the migration, but another way is:
Update-Database -Script
that open another file in Visual Studio with the sql code.
Thats is the only ways for get the sql code of migration. You can not to get the sql code of migration in debug because the migration run like power shell, and because it don't run the project.
Editing:
You can not go to into the migration or debbug it because the migration run like a power shell command.
You can to get the Entity Framework>Migration source code in entityframework.codeplex.com
Upvotes: 1
Reputation: 3659
I don't think you can output it directly, but you can use tracing and debug commands and attach another instance of VS to see the output.
Taken from this question: Where can I find the console or debug output from code executed in the package manager window?
Upvotes: 1