Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:54:56+00:00 2026-05-31T06:54:56+00:00

I am following one of the example from http://kazimanzurrashid.com/posts/entity-framework-code-first-bootstrapping In that post Kazi used

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:54:58+00:00Added an answer on May 31, 2026 at 6:54 am

    Try this for the registration

    public class DataAccessModule : UnityContainerExtension
    {
      protected override void Initialize()
      {
        this.Container.RegisterType<DataContextFactory>(new HttpContextLifetimeManager(), 
          new InjectionFactory(c => new DataContextFactory("DefaultConnection")));
        this.Container.RegisterType<DataContext>(
          new InjectionFactory(c => c.Resolve<DataContextFactory>().GetContext()));
        this.Container.RegisterType(typeof(IRepository<>), typeof(Repository<>));
      }
    }
    

    A sample for the HttpContextLifetimeManagercan be found here.

    You need to add the DataAccessModule to your container in your composition root.

    container.AddNewExtension<DataAccessModule>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how
Consider the following example taken from http://www.albahari.com/threading/ : using System; using System.Threading; class ThreadTest
In one example from http://leepoint.net/notes-java/data/expressions/precedence.html The following expression 1 + 2 - 3 *
I'm getting the following from a third party library (one example): @%SystemRoot%\SomePath\SomeFile.Dll,-203 I know
Given the following HTML example... <div id='div1'>div one</div> <div id='div2'>div two</div> ...I found that
does any one know if, for example, I'm writing in c++ the following code:
I'm learning about using Custom Views from the following: http://developer.android.com/guide/topics/ui/custom-components.html#modifying The description says: Class
I'm having problems doing the Database example from PhoneGap. http://docs.phonegap.com/phonegap_storage_storage.md.html#openDatabase The Problem is, when
Im working with the code below from here: http://api.jquery.com/jQuery.getJSON/ $.getJSON(http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?, { format: json },
From the website http://www.mobilepythonbook.org/ I found the following example of bluetooth sockets: BT chat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.