-1

i need to use StructureMap for register interface .

i need to register unitofwork in StructureMap .

Definition of unitowork methods in ApplicationDBContext . now how can i register unitofwork ?

        public static void InitIoC()
    {
        var container = new Container(_ =>
        {
            _.For<IUnitOfWork>().Use<ApplicationDBContext>(new ApplicationDBContext());
            _.For<IUser>().Use<EFUserService>();
        });

        // Now, resolve a new object instance of IFoo
        container.GetInstance<IUser>();
    }

it not work .

The type 'DbContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=19f9d7d4cc76b670'.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
کیانوش
  • 3
  • 1
  • 5

1 Answers1

0

I think you are confused where to register. You have to register your UnitOfWork where you are registering your repositories. You can find same problem here. Dependency injection in unit of work pattern using repositories

Dalvinder Singh
  • 251
  • 2
  • 11