Search code examples
c#entity-frameworkef-code-firstdatabase-migrationentity-framework-core

EF Core Add Migration Debugging


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.


Solution

  • 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.