Previously i had to implement IDesignTimeDbContextFactory to get migrations running, e.g: PM > Add-Migration Initial PM > Update-Database
If not, the console threw an error and led me here: https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext#use-idesigntimedbcontextfactory.
So i did what it suggested and got migrations running. After that i have created new projects, and i didn't have to implement the IDesignTimeDbContextFactory. Migrations worked anyway. How is this possible? Same .NET Core version (2.0) on all of the projects.
Do we always need to create a IDesignTimeDbContextFactory, or is it just in certain situations?
Thanks!
Okay, here it goes: If you have a default constructor in your DbContext or are using the Program.BuildWebHost() pattern established in the ASP.NET Core 2.0 project templates, you typically won't need an IDesignTimeDbContextFactory implementation.
In 2.0.0-preview1 Program.BuildWebHost() wasn't used and you needed a design-time factory.
See this thread for full discussion: https://github.com/aspnet/EntityFrameworkCore/issues/9033