Click here to Skip to main content
15,895,779 members
Articles / Web Development / ASP.NET

Generic repository pattern using EF with Dependency injection (Ninject)

Rate me:
Please Sign up or sign in to vote.
4.88/5 (12 votes)
14 May 2013CPOL4 min read 114.5K   4.8K   40  
How to perform CRUD operations using generic repository with EF pattern with and dependency injection.
namespace Mvc4Application
{
    using System.Web.Mvc;
    using System.Web.Optimization;
    using System.Web.Routing;
    using Mvc4Application.Infrastructure;
    using Ninject;
    using Ninject.Web.Common;

    // Note: For instructions on enabling IIS6 or IIS7 classic mode,
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : NinjectHttpApplication
    {
        protected override IKernel CreateKernel()
        {
            var kernel = new StandardKernel(new AppModule());
            return kernel;
        }

        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();

            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions