title: ASP.NET MVC 3 Implementing Unit Of Work using DI and Repository with EF
body: <p>So, I am trying to implement best practices during the design phase of a system.  I am going to be using a DI container (ninject) with Entity Framework 4, ASP.NET MVC 3 C#, and the repository / unit of work pattern.  </p>
  
  <p><li>I am going to have models where each database's tables are mapped to classes.</li>
  <li>I am going to have a connection string for each database in web.config.</li>
  <li>I am going to have a class for each connection string (named the same using EF convention) which inherits from DbContext and has a DbSet for each table.</li>
  <li>I am going to have an abstract repository interface for each database entity named by convention ITRepository where T is the name of the DataBase entity (ICarRepository for database entity Car).  Each repository interface will hold an IQueryable for the entity and also define what methods should be exposed.</li>
  <li>I am going to have a concrete repository EFTRepository which inherits from ITRepository and defines how the exposed methods work.
  <li>I am going to have a <code>GenericRepository&lt;TEntity&gt;</code> defined for use with entities that require only minimal access such as basic CRUD.</li>
  <li>I am going to use a ControllerFactory from <a href="http://www.ninject.org" rel="nofollow">ninject</a> as a DI container.</li>
  <li>I am going to attach the ninject controller factory in Application_Start().</li>
  <li>I am going to bind all my dependencies, such as <code>Bind&lt;ITRepository&gt;().To&lt;EFTRepository&gt;()</code> in the factory's AddBindings() method.</li>
  <li>I am going to implement a Unit Of Work pattern for each database and keep to naming conventions UnitOfWorkDB (UnitOfWorkAutomobile for database Automobile).</li>
  <li>The Unit Of Work will hold the relevant database context and repositories.</li></p>
  
  <p>Am I going about this right? I haven't used this set of patterns before and want to make sure I am going to be using them correctly. Criticisms welcome!</p>