EF Core Add Migration Debugging

Jeremy Holovacs picture Jeremy Holovacs · Jan 15, 2017 · Viewed 7.2k times · Source

How can I step into OnModelCreating with a breakpoint and see if my logic is wrong or if the ModelBuilder is doing something I'm not expecting? I've seen lots of posts on how to debug the actual migration, but nothing on how to watch how the model code is being generated.

I'm trying to implement some custom attributes on some of my entities, and it's being ignored; I'd like to see what my configuration is doing as it's generating the model code.

Answer

bricelam picture bricelam · Jan 20, 2017

You should be able to call Debugger.Launch() in your code. The just-in-time debugger should prompt you to attach a debugger when it hits that line.