Can one set a breakpoint in EF code first migrations seed method? Can one set a breakpoint in EF code first migrations seed method? asp.net asp.net

Can one set a breakpoint in EF code first migrations seed method?


It's not possible directly within source code but you can attach the debugger via source code. Please see this link for details:

if (System.Diagnostics.Debugger.IsAttached == false)   System.Diagnostics.Debugger.Launch();

The other option would be to run the migration via source code as explained above:

var configuration = new Configuration();var migrator = new DbMigrator(configuration);migrator.Update();


Update-Database runs out of your debugging session so you cannot set a breakpoint. You'll want to run your Seed method elsewhere from within your code, like a dummy method, that you can kick off from within your app.