title: Entity Framework core navigation property between two contexts
body: <p>There are similar questions with this issue, but not for EF Core. Not a duplicate of <a href="https://stackoverflow.com/questions/43767933/entity-framework-core-using-multiple-dbcontexts">Entity Framework Core Using multiple DbContexts</a> . That one is related to not being able to access the database at all from the second context, and the two contexts use different databases. This question is about a single database and the issue is related to migrations</p>
  
  <hr>
  
  <p>I have two EF core db contexts using the same SQL Server database.</p>
  
  <p>In the first context I have many entities, one of them is User.</p>
  
  <p>In the second one there is a single entity called UserExt which has a navigational property to User</p>
  
  <pre><code>public class UserExt
  {
      [Key]
      public long UserID { get; set; }
      public virtual User User { get; set; }
  
      [Required]
      public string Address { get; set; }
  }
  </code></pre>
  
  <p>The issue is that when creating the migration for UserExt using 'add-migration', all entities from the first context are also included.</p>
  
  <p>Tried providing the context, but same result</p>
  
  <pre><code>add-migration --context SecondContext
  </code></pre>
  
  <p>With EF 6 it was possible to solve this using ContextKey (<a href="https://msdn.microsoft.com/en-us/library/system.data.entity.migrations.dbmigrationsconfiguration.contextkey(v=vs.113).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/system.data.entity.migrations.dbmigrationsconfiguration.contextkey(v=vs.113).aspx</a>) but has not been ported to EF Core</p>
  
  <p>Is there a way to make this work so that the migrations in the second context would contain only its entities ?</p>