I am following one of the example from http://kazimanzurrashid.com/posts/entity-framework-code-first-bootstrapping
In that post Kazi used Ninject but in my case I choose Unity as my IOC container.
I am finding difficuty in translating the following niject module code in to Unity code. All the help will be apreciated.
public class DataAccessModule : NinjectModule
{
public override void Load()
{
Bind<DataContextFactory>()
.ToMethod(c => new DataContextFactory("DefaultConnection"))
.InRequestScope();
Bind<DataContext>()
.ToMethod(c => c.Kernel.Get<DataContextFactory>().GetContext());
Bind(typeof(IRepository<>)).To(typeof(Repository<>));
Bind<UnitOfWork>().ToSelf();
}
}
Thanks in advance!
Try this for the registration
A sample for the
HttpContextLifetimeManagercan be found here.You need to add the
DataAccessModuleto your container in your composition root.