title: Advice on the repository pattern with MVC3 & EF
body: <p>I had a discussion with another developer regarding the repostory pattern with mvc3 and the EF that has gotten me sightly confused.</p>
  
  <p>I am not sure the best practice to follow using the repository pattern with MVC3 and the EF.</p>
  
  <p>Lets say I have a table called Product containing ProductID &amp; ProductName. I create my new EF model.
  I also create a basic model ProductModel</p>
  
  <pre><code>public int ProductID{get;set:}
  public string ProductName{get;set}
  </code></pre>
  
  <p>Should my controller know anything about my entity created by the EF? or am I meant to be doing all my talking to the EF inside my repository?</p>
  
  <p>e.g. A basic post </p>
  
  <pre><code>[HttpPost]
  public ActionResult Product(ProductModel model)
  </code></pre>
  
  <p>Then in my controller, I pass the model to my repository to take care of the insert or should my controller be bound to directly to my EF Product Model and then pass that to my repository to take care of the insert.</p>
  
  <p>I thought the idea of the using the repository is that lets say in 12 months time if I wanted to stripe out the entity framework and use something else I would only need to update my repository and wouldn't have to touch any of my controllers.</p>
  
  <p>What is the best practice?</p>