Each time I run Update-Database from the package manager console, Visual Studio 2015 is crashing. It happens to be running my migrations Configuration.Seed method at the time. Any idea where I should look to find out what's going on?
There is a non-trivial chance that the crash is caused by project's code and not the inner working of Visual Studio.
As suggested by m_david in a question linked by the OP, the first step is to add following code at the beginning of Seed()
¹:
if (System.Diagnostics.Debugger.IsAttached == false)
{
System.Diagnostics.Debugger.Launch();
}
This will cause a prompt² to appear that will ask whether to launch the debugger in a new instance of Visual Studio or another currently running one.
After that, the debugger's output will be logged to Debug output of that VS instance, and unhandled exceptions will be treated as break points - with highlighting the offending line of code, exception details and all that.
In my case, the crash was caused by a recursive set()
operation in a member of one of the entities, which resulted in a StackOverflowException
.
¹ Or your DbMigrationsConfiguration
subclass's constructor, if the crash happens earlier. Or possibly some other place.
² So remember to comment that code out when you don't need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With