如何DbContext
在应用层获取实例?
我试过:
1.
public class SeedingTestDataAppService : MyAppServiceBase
{
private readonly MyDbContext _ctx;
public SeedingTestDataAppService
(
MyDbContext context // Error
)
{
_ctx = context;
}
}
2.
public class SeedingTestDataAppService : MyAppServiceBase
{
private readonly MyDbContext _ctx;
public SeedingTestDataAppService
(
IDbContextProvider<MyDbContext> dbContextProvider
)
{
_ctx = dbContextProvider.GetDbContext();
// Error: unitOfWork is null
}
}
我不擅长 ABP。我在哪里以及如何获取DbContext
实例并注入它?