public TDbContext Get <TDbContext>() where TDbContext : DbContext
    {
        var ambientDbContextScope = DbContextScope.GetAmbientScope();

        if (ambientDbContextScope == null)
        {
            throw new InvalidOperationException(
                      "No ambient DbContext scope found. The method has been called outside of the DbContextScope.");
        }

        return(ambientDbContextScope.DbContexts.Get <TDbContext>());
    }
Exemple #2
0
        public TDbContext Get <TDbContext>() where TDbContext : class
        {
            var ambientDbContextScope = DbContextScope.GetAmbientScope();

            return(ambientDbContextScope?.DbContexts.Get <TDbContext>());
        }