title: What's the most efficient way to inject behavior into all my entities?
body: <p>I'm converting a large data model from an old Microsoft data access library to Entity Framework 4. I'd like to "inject" these two methods into most, if not all, of the entities that have been generated from the existing database into my EF model:</p>
  
  <pre><code>    public bool Deleted
      {
          get { return this.EntityState == System.Data.EntityState.Deleted; }
          set 
          {
              if (value)
                  Context.DeleteObject(this);
          }
      }
  
      public bool Inserted
      {
          get { return this.EntityState == System.Data.EntityState.Added; }
          set
          {
              if (value)
                  Context.AddObject(this.GetType().Name, this);
          }
      }
  </code></pre>
  
  <p>Rather than creating a partial class for each entity (there are over 100), what's the better way to add these methods to all the entities in the model?</p>
  
  <p>Thanks in advance for your suggestions.</p>