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