Debugging the Seed() method – Entity Framework migrations

This one has been fun. I’ve had a couple of issues when attempting to seed the ASP.NET Identity database using Entity Framework Code First migrations.

You would normally run the migrations via the Package Manager Console when developing locally, but this has an unfortunate side-effect – you can’t debug in the normal manner. If you have problems with your Seed method not working, as I have, it makes it rather difficult to figure out. Additionally, Console.WriteLine(), Debug.WriteLine(), Trace.WriteLine() etc don’t output to the Package Manager Console.

The solution? Open another instance of Visual Studio and attach the debugger to the original instance. Sorted.

Leave a Reply