Closed starmandeluxe closed 5 years ago
This library isn't really built to work with .NET Core, although I assume some people have managed to make it work. You might want to check out a fork that (in theory) has been updated to work with Core: https://github.com/apawsey/DbContextScope
Disclaimer: I haven't had a need to move to .NET Core yet, so I don't have any first-hand experience with what does and what doesn't work.
Hmmm, actually I checked in Nuget Manager and that's precisely the fork I have installed currently. I will post this question on his fork instead.
I am using .NET Core 1.1 and EF Core, in which my MyDbContext simply inherits from EntityFrameworkCore.DbContext. Unfortunately, DbContextScope expects only an EntityFramework.DbContextScope.IDbContext. How do I resolve this?
I tried implementing the OnConfiguring method in MyDbContext and manually provided the connection string, and while this does get it working, I don't like having to provide the connection string inside there since it's being handled by .NET Core's Startup.cs already:
services.AddDbContext<MyDbContext>(options => options.UseSqlServer("connection string here"));