public virtual Type GetContextType([CanBeNull] string name)
        {
            var contextType = FindContextType(name);

            _logger.Value.LogVerbose(CommandsStrings.LogUseContext(contextType.Name));

            return(contextType);
        }
Exemple #2
0
        public virtual DbContext CreateContext([CanBeNull] string contextType)
        {
            var context = FindContextType(contextType).Value();

            _logger.Value.LogDebug(CommandsStrings.LogUseContext(context.GetType().Name));

            var loggerFactory = context.GetService <ILoggerFactory>();

            loggerFactory.AddProvider(_loggerProvider);

            return(context);
        }
        private DbContext CreateContext(Func <DbContext> factory)
        {
            var context = factory();

            _logger.Value.LogDebug(CommandsStrings.LogUseContext(context.GetType().Name));

            var loggerFactory = context.GetService <ILoggerFactory>();

            loggerFactory.AddProvider(_loggerProvider);

            return(context);
        }