Why we need to implement repository pattern
The main problem with this design is : our controller is tightly coupled with the DataAccess layer. UnitTest will be difficult to implement for the controller. It will have a side effect while implementing.means when you are going to test this application you should not be creating rows in real database. It will be hard to extend our domain-specific behaviour for entities. to overcome all problem we need to go with REPOSITORY Pattern. Now what will get if we introduce Repository Pattern in between: The consumer(controller) is now separated (decoupled) from data acess. Easy to write unit test without having any side-effects. Modify and extend entities before they are passed on to the consumer. We have now less duplication of code as its sharable abstraction. so when we are going to implement Repository Pattern we need to always go for generic implemcntation. public interface IRepository<T>{ T Add(T entity); T Get(Guid id); T Update(T entity); IEnumerable<...