Open Rennix09 opened 6 years ago
Hi Create own CallContext or use Async as System.Runtime.Remoting.Messaging.CallContext is not supported in Core 2.0
public static class CallContext
{
static ConcurrentDictionary<string, AsyncLocal<object>> dict= new
ConcurrentDictionary<string, AsyncLocal<object>>();
public static void LogicalSetData(string name, object data) =>
dict.GetOrAdd(name, _ => new AsyncLocal<object>()).Value = data;
public static object LogicalGetData(string name) =>
dict.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
}
You can use my library https://github.com/dojo90/DbContextScope
Already made a nuget package out of it.
I have register the factory and locator,
services.AddScoped<DbContextScope.EfCore.Interfaces.IAmbientDbContextLocator>(serviceProvider => new DbContextScope.EfCore.Implementations.AmbientDbContextLocator());
and the locator register as :services.AddScoped<IDbContextScopeFactory>(serviceProvider => new DbContextScopeFactory());
but when I create a scope instance useusing ( var scope =_dbContextScopeFactory.Create()){}
I get a exception:what shoud i do ? thank you .