title: EntityFramework 6 - Get DbSet<> without registering model in context
body: <p>In Linq-to-sql i am able to get a table without registering model in the context.
  However, in EF i get the <code>The entity type A is not part of the model for the current context.</code> error.</p>
  
  <p>Below is the code listing:</p>
  
  <pre><code>class Program
    {
      static void Main(string[] args)
      {
        const string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=Test";
  
        var ctx = new MyContext(constr);
        var table = ctx.GetTable&lt;A&gt;();
  
        var a = table.FirstOrDefault();
  
        var efCtx = new EfContext(constr);
        var set = efCtx.Set&lt;A&gt;();
        var b = set.FirstOrDefault();
      }
    }
  
    [System.Data.Linq.Mapping.Table]
    class A
    {
      [System.Data.Linq.Mapping.Column]
      [Key]
      public Guid Id { get; set; }
      [System.Data.Linq.Mapping.Column]
      public string B { get; set; }
    }
  
    class EfContext : DbContext
    {
      public EfContext(string con)
        : base(con)
      {
      }
    }
  
    class MyContext : DataContext
    {
      public MyContext(string fileOrServerOrConnection)
        : base(fileOrServerOrConnection)
      {
      }
    }
  </code></pre>
  
  <p>The exception is thrown on this line <code>var set = efCtx.Set&lt;A&gt;();</code></p>
  
  <p>Is it possible to use EF the same way as linq-to-sql?</p>