michielpost.nl

NuGet Unity MVC3 EntityFramework Quickstart

24-06-2011

NuGet Quickstart for using Unity and EntityFramework (code first) in an MVC 3 project. By using this Quickstart your Dependency Injection and EntityFramework are all setup and ready to go.

http://nuget.org/List/Packages/Unity.Mvc3.EntityFramework.Quickstart

Data, Domain and Service layers are installed in sample directories:
SAMPLE_Data
SAMPLE_Domain
SAMPLE_Services

A UnitySetup.cs is installed in App_Start, this is where you fill the UnityContainer.

The Unity.Mvc3 NuGet package is used, it has a great Http Module that properly disposed the EntityFramework DataContext.

Let me know if you find any bugs or have improvements.

Comments


Michiel 14-07-2011
Helper for Linq to SQL string connectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; var injectedConnectionString = new InjectionConstructor(connectionString); mainContainer.RegisterType<DataClasses1DataContext>(new HierarchicalLifetimeManager(), injectedConnectionString);


Richard 06-01-2012
Hi, could you expand this sample to include the controller and view so we can see this actually run? With the sample installed in an empty mvc app, I'm not sure what to do now...


Mike Wassermann 14-02-2012
Hi, this looks good, but I am new and need documentation on how this example works. Mike Wassermann


New Comment

Name
E-mail (not published)
Comment
Enter the code shown: