Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在StructureMap中注册unitofwork_C#_Structuremap - Fatal编程技术网

C# 在StructureMap中注册unitofwork

C# 在StructureMap中注册unitofwork,c#,structuremap,C#,Structuremap,我需要使用StructureMap作为注册接口 我需要在StructureMap中注册unitofwork ApplicationDBContext中的unitowork方法定义。现在我如何注册unitofwork public static void InitIoC() { var container = new Container(_ => { _.For<IUnitOfWork>().Use&

我需要使用StructureMap作为注册接口

我需要在StructureMap中注册unitofwork

ApplicationDBContext
中的unitowork方法定义。现在我如何注册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>();
    }
publicstaticvoidinitioc()
{
var container=新容器(=>
{
_.For().Use(新应用程序上下文());
_.For().Use();
});
//现在,解析IFoo的一个新对象实例
container.GetInstance();
}
它不起作用

类型“DbContext”是在未引用的程序集中定义的。必须添加对程序集“EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=19f9d7d4cc76b670”的引用


我想你不知道在哪里注册。您必须在注册存储库的地方注册UnitOfWork。 你可以在这里找到同样的问题。

错误很明显。你有什么问题?另外,您的问题是在文本中包含所有详细信息,而不是截图。@J.Steen我如何注册unitofwork?@J.Steen我编辑过