Пример #1
16
        public RelationalScaffoldingModelFactory(
            [NotNull] IOperationReporter reporter,
            [NotNull] IRelationalTypeMapper typeMapper,
            [NotNull] IDatabaseModelFactory databaseModelFactory,
            [NotNull] ICandidateNamingService candidateNamingService,
            [NotNull] IPluralizer pluralizer,
            [NotNull] ICSharpUtilities cSharpUtilities,
            [NotNull] IScaffoldingTypeMapper scaffoldingTypeMapper)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(databaseModelFactory, nameof(databaseModelFactory));
            Check.NotNull(candidateNamingService, nameof(candidateNamingService));
            Check.NotNull(pluralizer, nameof(pluralizer));
            Check.NotNull(cSharpUtilities, nameof(cSharpUtilities));
            Check.NotNull(scaffoldingTypeMapper, nameof(scaffoldingTypeMapper));

            Reporter               = reporter;
            TypeMapper             = typeMapper;
            CandidateNamingService = candidateNamingService;
            _databaseModelFactory  = databaseModelFactory;
            _pluralizer            = pluralizer;
            _cSharpUtilities       = cSharpUtilities;
            _scaffoldingTypeMapper = scaffoldingTypeMapper;
        }
Пример #2
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public MigrationsOperations(
            [NotNull] IOperationReporter reporter,
            [NotNull] Assembly assembly,
            [NotNull] Assembly startupAssembly,
            [NotNull] string projectDir,
            [NotNull] string rootNamespace,
            [CanBeNull] string language,
            [NotNull] string[] args)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(assembly, nameof(assembly));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotNull(projectDir, nameof(projectDir));
            Check.NotNull(rootNamespace, nameof(rootNamespace));
            Check.NotNull(args, nameof(args));

            _reporter          = reporter;
            _assembly          = assembly;
            _projectDir        = projectDir;
            _rootNamespace     = rootNamespace;
            _language          = language;
            _contextOperations = new DbContextOperations(
                reporter,
                assembly,
                startupAssembly,
                args);

            _servicesBuilder = new DesignTimeServicesBuilder(startupAssembly, reporter, args);
        }
Пример #3
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public CompiledModelScaffolder(
     ICompiledModelCodeGeneratorSelector modelCodeGeneratorSelector,
     IOperationReporter reporter)
 {
     ModelCodeGeneratorSelector = modelCodeGeneratorSelector;
     _reporter = reporter;
 }
Пример #4
0
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="MigrationsScaffolder" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///         directly from your code. This API may change or be removed in future releases.
        ///     </para>
        /// </summary>
        /// <param name="currentDbContext"> The current DbContext. </param>
        /// <param name="model"> The model. </param>
        /// <param name="migrationsAssembly"> The migrations assembly. </param>
        /// <param name="migrationsModelDiffer"> The migrations model differ. </param>
        /// <param name="migrationsIdGenerator"> The migrations ID generator. </param>
        /// <param name="migrationCodeGenerator"> The migrations code generator. </param>
        /// <param name="historyRepository"> The history repository. </param>
        /// <param name="operationReporter"> The operation reporter. </param>
        /// <param name="databaseProvider"> The database provider. </param>
        /// <param name="snapshotModelProcessor"> The snapshot model processor. </param>
        public MigrationsScaffolderDependencies(
            [NotNull] ICurrentDbContext currentDbContext,
            [NotNull] IModel model,
            [NotNull] IMigrationsAssembly migrationsAssembly,
            [NotNull] IMigrationsModelDiffer migrationsModelDiffer,
            [NotNull] IMigrationsIdGenerator migrationsIdGenerator,
            [NotNull] IMigrationsCodeGenerator migrationCodeGenerator,
            [NotNull] IHistoryRepository historyRepository,
            [NotNull] IOperationReporter operationReporter,
            [NotNull] IDatabaseProvider databaseProvider,
            [NotNull] ISnapshotModelProcessor snapshotModelProcessor)
        {
            Check.NotNull(currentDbContext, nameof(currentDbContext));
            Check.NotNull(model, nameof(model));
            Check.NotNull(migrationsAssembly, nameof(migrationsAssembly));
            Check.NotNull(migrationsModelDiffer, nameof(migrationsModelDiffer));
            Check.NotNull(migrationsIdGenerator, nameof(migrationsIdGenerator));
            Check.NotNull(migrationCodeGenerator, nameof(migrationCodeGenerator));
            Check.NotNull(historyRepository, nameof(historyRepository));
            Check.NotNull(operationReporter, nameof(operationReporter));
            Check.NotNull(databaseProvider, nameof(databaseProvider));
            Check.NotNull(snapshotModelProcessor, nameof(snapshotModelProcessor));

            CurrentDbContext       = currentDbContext;
            Model                  = model;
            MigrationsAssembly     = migrationsAssembly;
            MigrationsModelDiffer  = migrationsModelDiffer;
            MigrationsIdGenerator  = migrationsIdGenerator;
            MigrationCodeGenerator = migrationCodeGenerator;
            HistoryRepository      = historyRepository;
            OperationReporter      = operationReporter;
            DatabaseProvider       = databaseProvider;
            SnapshotModelProcessor = snapshotModelProcessor;
        }
Пример #5
0
        public MigrationsOperations(
            [NotNull] IOperationReporter reporter,
            [NotNull] Assembly assembly,
            [NotNull] Assembly startupAssembly,
            [CanBeNull] string environment,
            [NotNull] string projectDir,
            [NotNull] string contentRootPath,
            [NotNull] string rootNamespace)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(assembly, nameof(assembly));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotNull(projectDir, nameof(projectDir));
            Check.NotEmpty(contentRootPath, nameof(contentRootPath));
            Check.NotNull(rootNamespace, nameof(rootNamespace));

            _reporter          = reporter;
            _assembly          = assembly;
            _projectDir        = projectDir;
            _rootNamespace     = rootNamespace;
            _contextOperations = new DbContextOperations(
                reporter,
                assembly,
                startupAssembly,
                environment,
                contentRootPath);

            var startup = new StartupInvoker(reporter, startupAssembly, environment, contentRootPath);

            _servicesBuilder = new DesignTimeServicesBuilder(startup);
        }
Пример #6
0
    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public MigrationsOperations(
        IOperationReporter reporter,
        Assembly assembly,
        Assembly startupAssembly,
        string projectDir,
        string?rootNamespace,
        string?language,
        bool nullable,
        string[]?args)
    {
        _reporter          = reporter;
        _assembly          = assembly;
        _projectDir        = projectDir;
        _rootNamespace     = rootNamespace;
        _language          = language;
        _nullable          = nullable;
        _args              = args ?? Array.Empty <string>();
        _contextOperations = new DbContextOperations(
            reporter,
            assembly,
            startupAssembly,
            projectDir,
            rootNamespace,
            language,
            nullable,
            _args);

        _servicesBuilder = new DesignTimeServicesBuilder(assembly, startupAssembly, reporter, _args);
    }
Пример #7
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public MigrationsOperations(
            [NotNull] IOperationReporter reporter,
            [NotNull] Assembly assembly,
            [NotNull] Assembly startupAssembly,
            [NotNull] string projectDir,
            [NotNull] string rootNamespace,
            [CanBeNull] string language,
            [NotNull] string[] args)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(assembly, nameof(assembly));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotNull(projectDir, nameof(projectDir));
            Check.NotNull(rootNamespace, nameof(rootNamespace));
            // Note: cannot assert that args is not null - as old versions of
            // tools can still pass null.

            _reporter          = reporter;
            _assembly          = assembly;
            _projectDir        = projectDir;
            _rootNamespace     = rootNamespace;
            _language          = language;
            _args              = args ?? Array.Empty <string>();
            _contextOperations = new DbContextOperations(
                reporter,
                assembly,
                startupAssembly,
                _args);

            _servicesBuilder = new DesignTimeServicesBuilder(assembly, startupAssembly, reporter, _args);
        }
Пример #8
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public MigrationsOperations(
            IOperationReporter reporter,
            Assembly assembly,
            Assembly startupAssembly,
            string projectDir,
            string?rootNamespace,
            string?language,
            string[]?args)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(assembly, nameof(assembly));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotNull(projectDir, nameof(projectDir));

            _reporter          = reporter;
            _assembly          = assembly;
            _projectDir        = projectDir;
            _rootNamespace     = rootNamespace;
            _language          = language;
            _args              = args ?? Array.Empty <string>();
            _contextOperations = new DbContextOperations(
                reporter,
                assembly,
                startupAssembly,
                _args);

            _servicesBuilder = new DesignTimeServicesBuilder(assembly, startupAssembly, reporter, _args);
        }
Пример #9
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public ReverseEngineerScaffolder(
            IDatabaseModelFactory databaseModelFactory,
            IScaffoldingModelFactory scaffoldingModelFactory,
            IModelCodeGeneratorSelector modelCodeGeneratorSelector,
            ICSharpUtilities cSharpUtilities,
            ICSharpHelper cSharpHelper,
            INamedConnectionStringResolver connectionStringResolver,
            IOperationReporter reporter)
        {
            Check.NotNull(databaseModelFactory, nameof(databaseModelFactory));
            Check.NotNull(scaffoldingModelFactory, nameof(scaffoldingModelFactory));
            Check.NotNull(modelCodeGeneratorSelector, nameof(modelCodeGeneratorSelector));
            Check.NotNull(cSharpUtilities, nameof(cSharpUtilities));
            Check.NotNull(cSharpHelper, nameof(cSharpHelper));
            Check.NotNull(connectionStringResolver, nameof(connectionStringResolver));
            Check.NotNull(reporter, nameof(reporter));

            _databaseModelFactory = databaseModelFactory;
            _factory = scaffoldingModelFactory;
            ModelCodeGeneratorSelector = modelCodeGeneratorSelector;
            _cSharpUtilities           = cSharpUtilities;
            _code = cSharpHelper;
            _connectionStringResolver = connectionStringResolver;
            _reporter = reporter;
        }
Пример #10
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public StartupInvoker(
            [NotNull] IOperationReporter reporter,
            [NotNull] Assembly startupAssembly,
            [CanBeNull] string environment,
            [NotNull] string contentRootPath)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotEmpty(contentRootPath, nameof(contentRootPath));

            _reporter = reporter;

            _environment = !string.IsNullOrEmpty(environment)
                ? environment
                : "Development";

            _contentRootPath = contentRootPath;

            _startupAssemblyName = startupAssembly.GetName().Name;

            _startupType = startupAssembly.GetLoadableDefinedTypes().Where(t => typeof(IStartup).IsAssignableFrom(t.AsType()))
                           .Concat(startupAssembly.GetLoadableDefinedTypes().Where(t => t.Name == "Startup" + _environment))
                           .Concat(startupAssembly.GetLoadableDefinedTypes().Where(t => t.Name == "Startup"))
                           .Select(t => t.AsType())
                           .FirstOrDefault();

            _designTimeServicesType = startupAssembly.GetLoadableDefinedTypes()
                                      .Where(t => typeof(IDesignTimeServices).IsAssignableFrom(t.AsType())).Select(t => t.AsType())
                                      .FirstOrDefault()
                                      ?? _startupType;
        }
        public ColumnRemovingScaffoldingModelFactory([NotNull] IOperationReporter reporter, [NotNull] ICandidateNamingService candidateNamingService, [NotNull] IPluralizer pluralizer, [NotNull] ICSharpUtilities cSharpUtilities, [NotNull] IScaffoldingTypeMapper scaffoldingTypeMapper, [NotNull] LoggingDefinitions loggingDefinitions, List <SerializationTableModel> tables, DatabaseType databaseType) :
            base(reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, loggingDefinitions)
#endif
        {
            _tables       = tables;
            _databaseType = databaseType;
        }
Пример #12
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        protected DbContextOperations(
            IOperationReporter reporter,
            Assembly assembly,
            Assembly startupAssembly,
            string projectDir,
            string?rootNamespace,
            string?language,
            bool nullable,
            string[]?args,
            AppServiceProviderFactory appServicesFactory)
        {
            Check.NotNull(reporter, nameof(reporter));
            Check.NotNull(assembly, nameof(assembly));
            Check.NotNull(startupAssembly, nameof(startupAssembly));
            Check.NotNull(projectDir, nameof(projectDir));

            _reporter           = reporter;
            _assembly           = assembly;
            _startupAssembly    = startupAssembly;
            _projectDir         = projectDir;
            _rootNamespace      = rootNamespace;
            _language           = language;
            _nullable           = nullable;
            _args               = args ?? Array.Empty <string>();
            _appServicesFactory = appServicesFactory;
            _servicesBuilder    = new DesignTimeServicesBuilder(assembly, startupAssembly, reporter, _args);
        }
 // NB: Used by Scaffolding. Break with care.
 public DbContextOperations(
     [NotNull] IOperationReporter reporter,
     [NotNull] Assembly assembly,
     [NotNull] Assembly startupAssembly)
     : this(reporter, assembly, startupAssembly, new AppServiceProviderFactory(startupAssembly, reporter))
 {
 }
Пример #14
0
 public TestDbContextOperations(
     IOperationReporter reporter,
     Assembly assembly,
     Assembly startupAssembly,
     AppServiceProviderFactory appServicesFactory)
     : base(reporter, assembly, startupAssembly, appServicesFactory)
 {
 }
Пример #15
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public DbContextOperations(
     IOperationReporter reporter,
     Assembly assembly,
     Assembly startupAssembly,
     string[]?args)
     : this(reporter, assembly, startupAssembly, args, new AppServiceProviderFactory(startupAssembly, reporter))
 {
 }
 // This obsolete constructor maintains compatibility with Scaffolding
 public DbContextOperations(
     [NotNull] IOperationReporter reporter,
     [NotNull] Assembly assembly,
     [NotNull] Assembly startupAssembly,
     [CanBeNull] string environment,
     [CanBeNull] string contentRootPath)
     : this(reporter, assembly, startupAssembly)
 {
 }
Пример #17
0
 public TextTemplatingModelGenerator(
     ModelCodeGeneratorDependencies dependencies,
     ITextTemplating textTemplatingService,
     IOperationReporter reporter)
     : base(dependencies)
 {
     _host     = textTemplatingService;
     _reporter = reporter;
 }
Пример #18
0
 public FakeScaffoldingModelFactory(
     IOperationReporter reporter,
     ICandidateNamingService candidateNamingService,
     IPluralizer pluralizer,
     ICSharpUtilities cSharpUtilities,
     IScaffoldingTypeMapper scaffoldingTypeMapper)
     : base(reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper)
 {
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public DesignTimeServicesBuilder(
     [NotNull] Assembly startupAssembly,
     [NotNull] IOperationReporter reporter,
     [NotNull] string[] args)
 {
     _startupAssembly = startupAssembly;
     _reporter        = reporter;
     _args            = args;
 }
Пример #20
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public SnapshotModelProcessor([NotNull] IOperationReporter operationReporter)
 {
     _operationReporter = operationReporter;
     _relationalNames   = new HashSet <string>(
         typeof(RelationalAnnotationNames)
         .GetRuntimeFields()
         .Where(p => p.Name != nameof(RelationalAnnotationNames.Prefix))
         .Select(p => ((string)p.GetValue(null)).Substring(RelationalAnnotationNames.Prefix.Length - 1)));
 }
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public SnapshotModelProcessor(
     IOperationReporter operationReporter,
     IModelRuntimeInitializer modelRuntimeInitializer)
 {
     _operationReporter = operationReporter;
     _relationalNames   = new HashSet <string>(
         typeof(RelationalAnnotationNames)
         .GetRuntimeFields()
         .Where(p => p.Name != nameof(RelationalAnnotationNames.Prefix))
         .Select(p => ((string)p.GetValue(null) !)[(RelationalAnnotationNames.Prefix.Length - 1)..]));
Пример #22
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public CompiledModelScaffolder(
            ICompiledModelCodeGeneratorSelector modelCodeGeneratorSelector,
            IOperationReporter reporter)
        {
            Check.NotNull(modelCodeGeneratorSelector, nameof(modelCodeGeneratorSelector));
            Check.NotNull(reporter, nameof(reporter));

            ModelCodeGeneratorSelector = modelCodeGeneratorSelector;
            _reporter = reporter;
        }
Пример #23
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public DesignTimeServicesBuilder(
     Assembly assembly,
     Assembly startupAssembly,
     IOperationReporter reporter,
     string[] args)
 {
     _startupAssembly = startupAssembly;
     _reporter        = reporter;
     _args            = args;
     _assembly        = assembly;
 }
Пример #24
0
 public IServiceProvider CreateDesignServiceProvider(
     IServiceCollection customServices = null,
     Action <EntityFrameworkDesignServicesBuilder> replaceServices = null,
     Type additionalDesignTimeServices = null,
     IOperationReporter reporter       = null)
 => CreateDesignServiceProvider(
     CreateContext().GetService <IDatabaseProvider>().Name,
     customServices,
     replaceServices,
     additionalDesignTimeServices,
     reporter);
Пример #25
0
 public TestDatabaseOperations(
     IOperationReporter reporter,
     Assembly assembly,
     Assembly startupAssembly,
     string projectDir,
     string rootNamespace,
     string language,
     string[] args)
     : base(reporter, assembly, startupAssembly, projectDir, rootNamespace, language, args)
 {
 }
 public FakeScaffoldingModelFactory(
     IOperationReporter reporter,
     IPluralizer pluralizer)
     : base(
         reporter,
         new CandidateNamingService(),
         pluralizer,
         new CSharpUtilities(),
         new ScaffoldingTypeMapper(TestServiceFactory.Instance.Create <SqlServerTypeMapper>()))
 {
 }
Пример #27
0
 public FakeScaffoldingModelFactory(
     [NotNull] IOperationReporter reporter,
     [NotNull] IPluralizer pluralizer)
     : base(
         reporter,
         new CandidateNamingService(),
         pluralizer,
         new CSharpUtilities(),
         new ScaffoldingTypeMapper(new SqlServerTypeMapper(new RelationalTypeMapperDependencies())))
 {
 }
Пример #28
0
 public FakeScaffoldingModelFactory(
     IOperationReporter reporter,
     ICandidateNamingService candidateNamingService,
     IPluralizer pluralizer,
     ICSharpUtilities cSharpUtilities,
     IScaffoldingTypeMapper scaffoldingTypeMapper,
     LoggingDefinitions loggingDefinitions,
     IModelRuntimeInitializer modelRuntimeInitializer)
     : base(reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, loggingDefinitions, modelRuntimeInitializer)
 {
 }
Пример #29
0
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="operationReporter"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public MigrationsScaffolderDependencies With([NotNull] IOperationReporter operationReporter)
 => new MigrationsScaffolderDependencies(
     CurrentDbContext,
     Model,
     MigrationsAssembly,
     MigrationsModelDiffer,
     MigrationsIdGenerator,
     MigrationCodeGenerator,
     HistoryRepository,
     operationReporter,
     DatabaseProvider,
     SnapshotModelProcessor);
        /// <summary>
        ///     Adds the Entity Framework Core design-time services.
        /// </summary>
        /// <param name="services"> The <see cref="IServiceCollection" /> the services will be added to. </param>
        /// <param name="reporter"> Used to report design-time messages. </param>
        /// <param name="applicationServiceProviderAccessor"> An accessor to the application service provider. </param>
        /// <returns> The <paramref name="services" />. This enables chaining additional method calls. </returns>
        public static IServiceCollection AddEntityFrameworkDesignTimeServices(
            [NotNull] this IServiceCollection services,
            [CanBeNull] IOperationReporter reporter = null,
            [CanBeNull] Func <IServiceProvider> applicationServiceProviderAccessor = null)
        {
            if (reporter == null)
            {
                reporter = new OperationReporter(handler: null);
            }

            return(services
                   .AddSingleton <AnnotationCodeGeneratorDependencies>()
                   .AddSingleton <TypeMappingSourceDependencies>()
                   .AddSingleton <CSharpMigrationOperationGeneratorDependencies>()
                   .AddSingleton <CSharpMigrationsGeneratorDependencies>()
                   .AddSingleton <CSharpSnapshotGeneratorDependencies>()
                   .AddSingleton <MigrationsCodeGeneratorDependencies>()
                   .AddSingleton <ModelCodeGeneratorDependencies>()
                   .AddSingleton <ProviderCodeGeneratorDependencies>()
                   .AddSingleton <TypeMappingSourceDependencies>()
                   .AddSingleton <RelationalTypeMappingSourceDependencies>()
                   .AddSingleton <ValueConverterSelectorDependencies>()
                   .AddSingleton <ICandidateNamingService, CandidateNamingService>()
                   .AddSingleton <ICSharpDbContextGenerator, CSharpDbContextGenerator>()
                   .AddSingleton <ICSharpEntityTypeGenerator, CSharpEntityTypeGenerator>()
                   .AddSingleton <ICSharpHelper, CSharpHelper>()
                   .AddSingleton <ICSharpMigrationOperationGenerator, CSharpMigrationOperationGenerator>()
                   .AddSingleton <ICSharpSnapshotGenerator, CSharpSnapshotGenerator>()
                   .AddSingleton <ICSharpUtilities, CSharpUtilities>()
                   .AddSingleton(typeof(IDiagnosticsLogger <>), typeof(DiagnosticsLogger <>))
                   .AddSingleton <IInterceptors, Interceptors>()
                   .AddSingleton <DiagnosticSource>(new DiagnosticListener(DbLoggerCategory.Name))
                   .AddSingleton <ILoggingOptions, LoggingOptions>()
                   .AddSingleton <IMigrationsCodeGenerator, CSharpMigrationsGenerator>()
                   .AddSingleton <IMigrationsCodeGeneratorSelector, MigrationsCodeGeneratorSelector>()
                   .AddSingleton <IModelCodeGenerator, CSharpModelGenerator>()
                   .AddSingleton <IModelCodeGeneratorSelector, ModelCodeGeneratorSelector>()
                   .AddSingleton <IAnnotationCodeGenerator, AnnotationCodeGenerator>()
                   .AddSingleton <INamedConnectionStringResolver>(
                       new DesignTimeConnectionStringResolver(applicationServiceProviderAccessor))
                   .AddSingleton(reporter)
                   .AddSingleton <IPluralizer, HumanizerPluralizer>()
                   .AddSingleton <IReverseEngineerScaffolder, ReverseEngineerScaffolder>()
                   .AddSingleton <IScaffoldingModelFactory, RelationalScaffoldingModelFactory>()
                   .AddSingleton <IScaffoldingTypeMapper, ScaffoldingTypeMapper>()
                   .AddSingleton <IValueConverterSelector, ValueConverterSelector>()
                   .AddSingleton <IDbContextLogger, NullDbContextLogger>()
                   .AddTransient <MigrationsScaffolderDependencies>()
                   .AddTransient <IMigrationsScaffolder, MigrationsScaffolder>()
                   .AddTransient <ISnapshotModelProcessor, SnapshotModelProcessor>()
                   .AddLogging(b => b.SetMinimumLevel(LogLevel.Debug).AddProvider(new OperationLoggerProvider(reporter))));
        }