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.

Visual Studio – Add Controller dialog has empty Model Class and Data Context Class drop-downs

Update: I’ve just had a reoccurrence of the issue described below, and the steps I mention resolved it.

A very lengthy and precise title, but this one has been a bit of a pain in the arse. Google hasn’t helped much, so hopefully the next poor git who encounters this issue might stumble upon this post.

So, the problem is this – the ‘Add Controller’ dialog box in Visual Studio 2013 sometimes doesn’t populate he ‘Model Class’ and ‘Data Context Class’ dropdown boxes when you’re tried to add a new scaffolded controller to an MVC project.

Everything was working fine for me initially, and then it mysteriously stopped working. Googling seemed to suggest a simple rebuild of the project would do the trick (it didn’t).

It’s now working, and whilst I’m not sure it’s down to the fiddling I’ve down or just pure chance, here’s a list of the actions I took to attempt to resolve this very irritating problem:

– Unload the .csproj file
– Manually look through the .csproj for any dodgy references. I found VS had added to the web.config entry for no apparent reason. Everything else looked ok.
– Reload the the .csproj file
– Clean the solution
– Rebuild the solution

I’ll update if it breaks again and update the steps to resolve accordingly. I can’t seem to find any information that explains the datasource of that dialog – where it gets the model lists from.

Link to similar issue: