title: Circular dependency when generating dbcontext migrations into another assembly
body: <p>As the name suggests I have multiple projects, and one of the project contains the dbcontext and all the models. So, I want to generate migrations from that project and put all generated migrations into another assembly (<em>because I have multiple db providers for the same dbcontext, and one way is to move all migrations in different assemblies, so, i dont have problems later.</em>).</p>
  <p>Project containing the dbcontext and other stuff is not my main project, is just a class library.</p>
  <p>The structure of the solution looks like below:</p>
  <ul>
  <li>MyProject.DbContext</li>
  <li>MyProject.DbContext.Migrations</li>
  <li>MyProject</li>
  </ul>
  <p><strong>So, I reference the project <code>MyProject.DbContext.Migrations</code> from <code>MyProject.DbContext</code> to make the <code>dotnet ef ...</code> work,</strong> and I run this command:</p>
  <p><code>dotnet ef migrations add InitMySql --project ..\MyProject.DbContext.Migrations</code></p>
  <p>This will work fine as long as I do sth like this:</p>
  <pre><code> optionsBuilder.UseLazyLoadingProxies().UseMySql(configuration.ConnectionString, ServerVersion.AutoDetect(configuration.ConnectionString), builder =&gt;
   {
        builder.CommandTimeout(configuration.CommandTimeout);
        builder.UseNewtonsoftJson();
        builder.MigrationsAssembly(&quot;MyProject.DbContext.Migrations&quot;);
    });
  </code></pre>
  <p>But, now I have a big problem, the project <code>MyProject.DbContext.Migrations</code> needs also reference to <code>MyProject.DbContext</code> because of the new class created 'MyDbContextModelSnapshot' which has an attribute at the top: <code>[DbContext(typeof(MyDbContext))]</code> etc. Now I run into a circular dependency issue!</p>
  <p>How is this supposed to be solved ?</p>
  <p>I am currently using Asp.Net core 5, but I think this will happen for any version, seems more like a design limitation...</p>