Hi, I am Shashangka Shekhar, Working with Microsoft Technologies. This is my personal blog where I share some of my experiences.

ASP.Net MVC-5 CRUD Operation using Repository Pattern with SP

In this article we will focus on accessing data only using Stored Procedure using Entity Framework.

At first we need to create a database named CRUD_Sample. In sample db we have to create a table named Customer.

Store Procuders:

Repository Pattern:

The Repository Pattern allows to centralise all data access logic in one place.

It is a common construct to avoid duplication of data access logic throughout our application.

The Repository pattern adds a separation layer between the data and business layers of an application.

Generic Repository Pattern:

With generic feature, we can reduce the amount of code we need for common scenarios.

interface IRepository<T>

Show an interface of a generic repository of type T, which is a LINQ to SQL entity. It provides a basic interface with operations like Insert, Update, Delete, GetById and GetAll.


The IDisposable Interface, Provides a mechanism for releasing unmanaged resources.

where T : class

This is constraining the generic parameter to a class. Click for more

The type argument must be a reference type; this applies also to any class, interface, delegate, or array type.

Use of Middle-tire:

Use of Generic Repository in MVC-Application:

Source Code: I’ve uploaded the full source code to download/clone @github, Hope this will help 🙂


  • Reply priya |

    I am new to mvc in this , u didnt mention the connection string of database.not required?

    • Reply rakesh |

      Hi Priya,

      Here using entity data model, model name Customer_Entities. entity data model have a connection string

  • Reply ruchi |

    i am new in mvc , could u please tell me how i teach mvc with angular js very well.I wants ur all articles

Post a comment