title: How to extend an Entity Framework 6.1.3 generated class?
body: <p>Is it possible to extend an Entity Framework 6.1.3 generated class?</p>
  
  <p>I have an existing database to which I have created an ADO.NET Entity Data Model, which in turn Visual Studio 2015 has generated a set of classes.</p>
  
  <pre><code>public partial class WebApplication1Entities : DbContext
  {
      public WebApplication1Entities()
          : base("name=WebApplication1Entities")
      {
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          throw new UnintentionalCodeFirstException();
      }
  }
  </code></pre>
  
  <p>I can manually override the WebApplication1Entities to allow a dynamic runtime connection as so:</p>
  
  <pre><code>    public WebApplication1Entities(string connectionString) : base(connectionString)
      {
      }
  </code></pre>
  
  <p>This however, involves editing the class that Visual Studio 2015 has generated, but should I wish to update the ADO.NET Entity Data Model in the future, Visual Studio will overwrite any manual changes I have made to the previous generated class and I'm back to square one, having to manually edit the generated class.</p>
  
  <p>Is it possible to create a helper class or something similar to extend the existing <code>WebApplication1Entities : DbContext</code>, and allow the addition of the new overloaded method and also inherit the existing methods of the Visual Studio 2015 generated class such as virtual DbSets.</p>
  
  <p>Any help would be much appreciated :-)</p>