Search code examples
asp.netasp.net-mvcstack-overflowcode-first

Exception of type 'System.StackOverflowException' was thrown OnModelCreating in ASP.NET MVC


I have received StackOverflowException as when I want to run my project. I got this error several times but after a while it's gone and I didn't received it until now that I can't run my project at all. I don't know exactly why Visual studio 2019 can't run my project and build my context. For notice, I have a large database which I create my code first context by "CodeFirst From Database" operation.

This is image of Error


Solution

  • Just break your method into a few sub-methods and run your project.

    enter image description here

    enter image description here