You don’t need a IDesignTimeDbContextFactory

If you have ever gotten the error message, that tells you to add IDesignTimeDbContextFactory to your project, when doing EF Core migrations. This particular one: Unable to create an object of type ‘MyContext’. Add an implementation of ‘IDesignTimeDbContextFactory’ to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. You will probably be scratching your head, asking some questions and maybe even swear a little. Because the console will tell you to implemnt a IDesignTimeDbContextFactory so that is But don’t fret, you don’t need one. You can avoid it by having making sure of the following: The entire solution must be buildable and be able to run! If you have a project that cannot build, you can exclude it with the build configuration manager. Default constructor For the system to be able to build migrations from your context, it needs to be able to instantiate it with a default constructor! Implement the correct overloaded constructor! DbContextOptions<TContext> instead of DbContextOptions. ASP.NET Core If you are running an ASP.NET Core application, and you use the ServiceProvider (IoC) that is built in, then you must make sure that your DbContext and its’ dependencies are registered. You must also make sure that you are using the DbContextOptions<TContext> overloaded constructor and not the DbContextOptions overloaded constructor. When do I need a IDesignTimeDbContextFactory? When your DbContext exists in another project, like a shared library. Meaning that is has no context to run from. EF Core migrations works by actually running your code, if that is not possible, then you need to...