Entity-framework – Debug code-first Entity Framework migration codes

ef-code-firstentity-frameworkentity-framework-5entity-framework-migrations

I'm using Entity Framework code first in my website and I'm just wondering if there is any way to debug the migration codes. You know, like setting breakpoints and stuff like this.

I'm using Package Manager Console to update the database using Update-Database.

Thanks

Best Answer

I know that EF Code First Migrations is relatively new tool but don't forget about you are still in .NET.

So you can use:

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

After that you can see your InnerException.

Or you can use try...catch statement like this: Exception handling Entity Framework