I'm using GenericRepository pattern from https://github.com/huyrua/efprs. I just want to select constructor with DbContext as parameter. I know there's duplicate question, but solution from this didn't solve. Here's my configuration:
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.AssemblyContainingType<Data.Entity.TokoContainer>();
scan.WithDefaultConventions();
});
x.For<DbContext>().Use<Data.Entity.TokoContainer>();
x.For<Infrastructure.Data.IRepository>()
.Use<Infrastructure.Data.GenericRepository>()
.Ctor<DbContext>().Is(c => c.GetInstance<DbContext>());
});
this cause error "StructureMap Exception Code: There is no argument of type System.Data.Entity.DbContext for concrete type Infrastructure.Data.GenericRepository".
When using this:
x.SelectConstructor<Infrastructure.Data.IRepository>(() => new Infrastructure.Data.GenericRepository((DbContext)null));
x.ForConcreteType<Infrastructure.Data.IRepository>()
.Configure.Ctor<DbContext>().Is(c => c.GetInstance<DbContext>());
Causing "StructureMap configuration failures: Error 104".
Specifying from first code, adding parameter name "context" like this:
x.For<Infrastructure.Data.IRepository>()
.Use<Infrastructure.Data.GenericRepository>()
.Ctor<DbContext>("context").Is(c => c.GetInstance<DbContext>());
causing error "Missing requested Instance property "connectionStringName" for InstanceKey xxx". I don't know what to do now.
Any solution would be appreciated.