title: Partial class constructors and event handler registration
body: <p>I need to register an Event Handler for a class which is generated by a Template - the T4 Template within the EntityFramework.</p>
  
  <p>Currently, we have edited the generated code to register the handler within the Constructor of the generated class (the Model Context).</p>
  
  <p>Current code:</p>
  
  <pre><code>    public MyAppContext(string connectionString)
          : base(connectionString, ContainerName)
      {
          this.ContextOptions.LazyLoadingEnabled = true;
          // Register the event handler
          this.Connection.StateChange += Connection_StateChange;
      }
  </code></pre>
  
  <p>The problem is, if the code is ever re-generated in the future, then the above code will be clobbered and the Event Handler will no longer get hooked up...</p>
  
  <p>Code re-generation happens automatically from the smallest thing such as opening the EF Designer and moving a Table around on the canvas! So its imperative we DO NOT rely on leaving the custom code in the generated class.</p>
  
  <p>Is there anyway we can put the registration in a partial class and leave the generated code untouched???</p>
  
  <p>EG is there some sort of event that will always be fired once a constructor is called ?</p>