title: Best practices to perform CRUD operations on Entities (Entity Framework)
body: <p>I am trying to figure out where should I put database operation for each entity. Before this confusion,  for each entity, I was doing all these database operations in a provider class. Provider class means that each class has a provider. Such as:</p>
  
  <pre><code>class Member
  {
     public string FirstName;
     public string LastName;
  }
  
  class MemberProvider
  {
    //Singleton
    //Do database operations
  
     ......
  
     public List&lt;Member&gt; GetItems(FirstName = null, LastName = null)
     {
         // run store procedure
         //this returns List&lt;Member&gt; if any
     }
  
     public Member GetItem(int? Id = null,FirstName = null, LastName = null)
     {
         // run store procedure
         //this return Member if any
     }
  
     ....
  }
  </code></pre>
  
  <p>then when I need a list of member with some filtering, I do this:</p>
  
  <pre><code> List&lt;Member&gt; members = MemberProvider.Instance.GetItems(FirstName = "John", LastName = "Black");
  </code></pre>
  
  <p>The question is how can I do all this database operations related to entity in the entity itself ? Is it good practice ? What should I read to understand this concept ?</p>
  
  <p>Thanks in advance.</p>