I'm trying something fancy in a custom .NET 6 Entity Framework database migration. To be able to step through and follow the flow of my code, I set a breakpoint in the Up method before running dotnet ef database update
. But execution didn't stop at the breakpoint. Is there a way to run the migration in debug mode so that the breakpoint works?
The only occurrence of the word "debug" in the documentation at https://learn.microsoft.com/en-us/ef/core/cli/dotnet is in the command line argument --configuration Debug
. I added that to the database update command but it didn't achieve the result I'm looking for.
I do know that the Up method is being called because executing the migration gives me an error message in the PowerShell window that would be generated by a file read that occurs after the breakpoint (which is what I want to debug).
Use Debug
configuration
dotnet ef database update --configuration Debug
Put into your migration code Debugger.Launch()
:
protected override void Up(MigrationBuilder migrationBuilder)
{
Debugger.Launch();
... // rest of the code
}
After hitting Debugger.Launch()
, Windows will ask which debugger to use. The you will be able to debug your code.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments