using asp.net core(1.1) and structuremap (v4.4), I want to get instance of my dbContext (to insert seed data, etc.)
how can I get instance of my dbContext? I saw that the normal way is to inject IContainer container
into the class constructor, but in my integration test class the constructor will resolved before initialization of the container, (since in my test setup I call the startup class:
_server = new TestServer(new WebHostBuilder()
.UseEnvironment("testing")
.UseStartup<Startup>());
and the container initialized in statup class. (var container = new Container();
)
now I want to do in my test something like AbContext.Accounts.Add(new Account())
;
how can I get instance of Abcontext?
I think that with the deprecated static objectFactory - one can do it easily by objectFactory.Container.GetInstanse(). So, I'll be very happy to find the current equivalent for this.