Generic Repository Pattern in ASP.NET Core

A Visual Studio 2015 project which shows how to perform the create, read, update and delete operations in the ASP.NET Core application using generic repository pattern with Entity Framework Core Code First approach.

C# (1.1 MB)
4.5 Star
7,209 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Additional configuration after download
    2 Posts | Last post March 03, 2017
    • I had to run extra configuration In addition to author's instruction
      1. In nuget package manager console I ran "dotnet restore"
      2. At the end, I opened applicationhost.config and changed the physical path point to my project location. eg. <virtualDirectory path="/" physicalPath="C:\xxx\Generic Repository Pattern in ASP.NET Core\C#\GR.Web" />
      It worked for me. Hope this can help others who had the same problem like me.
      Thank you Sandeep, this is so beautiful code.
      I have a question: did you create a model and also create a model map manually? Because I see this pattern first time, could you tell me why did you use this pattern? Thanks.
    • Thanks Tiger Jin,These steps are awesome.I have an article for detail description. 
  • Controller error
    1 Posts | Last post February 21, 2017
    • Hi, I'm trying to implement your repository within my web project. I have a models folder where all the table classes DBContext and repositories are situated. I also added a BaseEntity class inwhich all my table classes inherit from. Now when I invoke my controller where I have instantiated the link to the Repository for my "User" class I get the following error thrown back from .net core:
      "InvalidOperationException: Unable to resolve service for type 'NetCoreAngular2.Models.IRepository`1[NetCoreAngular2.Models.User]' while attempting to activate 'NetCoreAngular2.Controllers.SampleDataController'."
      Do you have any idea what could be causing this?
      Thank you
  • solution name sucks
    1 Posts | Last post February 01, 2017
    • IMHO you should change solution name from "GenericReposotory.sln" to "GenericRepository.sln"
  • I get error I try to run the app
    5 Posts | Last post December 17, 2016
    • Here is the error I get:
      Detailed Error Information:
      Module	   IIS Web Core
      Notification	   Unknown
      Handler	   Not yet determined
      Error Code	   0x80070015
      Config Error	   Cannot read configuration file
      Config File	   \\?\E:\Sample\GenericReposotory\GR.Web\web.config
      Requested URL	   http://localhost:59832/
      Physical Path	   
      Logon Method	   Not yet determined
      Logon User	   Not yet determined
      Request Tracing Directory	   C:\Users\Ben\Documents\IISExpress\TraceLogFiles\
    • Thanks Ben,
      Please have a look on this solution
    • Thanks Sandeep;
      Changing the port # on GR.Web solved the problem.
    • Forgot to mention, nice work Sandeep.
    • Glad to see your problem solved. Thanks for the feedback!