title: Using same model class for two SQL tables with identical schema
body: <p>I am using EF Core 5 and I have an Azure SQL server with 2 tables that have identical schemas.</p>
  <p>The tables are (pseudo SQL):</p>
  <pre><code>Table1 (
           ID int PRIMARY KEY IDENTITY(1,1),
           Date datetime2(0),
           Title varchar(100)
         )
  
  Table2 (
           ID int PRIMARY KEY IDENTITY(1,1),
           Date datetime2(0),
           Title varchar(100)
         )
  </code></pre>
  <p>And my classes are like so:</p>
  <pre><code>public class TableRecord
  {
      public int Id { get; set; }
      public DateTime Date { get; set; }
      public string Title { get; set; }
  }
  
  public class MyContext : DbContext
  {
      public MyContext() { }
  
      public MyContext(DbContextOptions options) : base(options)
      {
          // This is for Managed Identity, ignore.
          var connection = (SqlConnection)Database.GetDbConnection();
          connection.AccessToken = new AzureServiceTokenProvider().GetAccessTokenAsync(&quot;https://database.windows.net/&quot;).Result;
      }
      
      public virtual DbSet&lt;TableRecord&gt; Table1 { get; set; }
  
      public virtual DbSet&lt;TableRecord&gt; Table2 { get; set; }
  }
  </code></pre>
  <p>and to get data I do:</p>
  <pre><code>// context is an instance of &quot;MyContext&quot; with SqlOptions passed in.
  var results = context.Table1.Where(x =&gt; x.Title.Contains(&quot;asd&quot;)).ToList();
  </code></pre>
  <p>however this gives me the error:
  <code>Invalid object name 'TableRecord'.</code></p>
  <p>If I just copy-paste the <code>TableRecord</code> class and rename both classes to something like <code>Table1Record</code> and <code>Table2Record</code> and change it so Table1's DbSet is of type &quot;Table1Record&quot; and similarly for Table2, it works. But it is annoying.</p>
  <p>Is there any way to tell EF Core that there are two separate tables, as I have defined them as two separate properties of the DbContext, but they have the same schema, so I want to use the same class for both of them?</p>