/// <summary> /// Used by database providers to create a new <see cref="EntityFrameworkServicesBuilder" /> for /// registration of provider services. Relational providers should use /// 'EntityFrameworkRelationalServicesBuilder'. /// </summary> /// <param name="serviceCollection"> The collection to which services will be registered. </param> public EntityFrameworkServicesBuilder([NotNull] IServiceCollection serviceCollection) { Check.NotNull(serviceCollection, nameof(serviceCollection)); ServiceCollectionMap = new ServiceCollectionMap(serviceCollection); }
/// <summary> /// Registers default implementations of all services, including relational services, not already /// registered by the provider. Relational database providers must call this method as the last /// step of service registration--that is, after all provider services have been registered. /// </summary> /// <returns> This builder, such that further calls can be chained. </returns> public override EntityFrameworkServicesBuilder TryAddCoreServices() { TryAdd <IParameterNameGeneratorFactory, ParameterNameGeneratorFactory>(); TryAdd <IComparer <ModificationCommand>, ModificationCommandComparer>(); TryAdd <IMigrationsIdGenerator, MigrationsIdGenerator>(); TryAdd <IKeyValueIndexFactorySource, KeyValueIndexFactorySource>(); TryAdd <IModelCustomizer, RelationalModelCustomizer>(); TryAdd <IMigrationsAnnotationProvider, MigrationsAnnotationProvider>(); TryAdd <IModelValidator, RelationalModelValidator>(); TryAdd <IMigrator, Migrator>(); TryAdd <IMigrationCommandExecutor, MigrationCommandExecutor>(); TryAdd <IMigrationsAssembly, MigrationsAssembly>(); TryAdd <IDatabase, RelationalDatabase>(); TryAdd <IBatchExecutor, BatchExecutor>(); TryAdd <IValueGeneratorSelector, RelationalValueGeneratorSelector>(); TryAdd <IRelationalCommandBuilderFactory, RelationalCommandBuilderFactory>(); TryAdd <IRawSqlCommandBuilder, RawSqlCommandBuilder>(); TryAdd <ICommandBatchPreparer, CommandBatchPreparer>(); TryAdd <IMigrationsModelDiffer, MigrationsModelDiffer>(); TryAdd <IMigrationsSqlGenerator, MigrationsSqlGenerator>(); TryAdd <IExecutionStrategyFactory, RelationalExecutionStrategyFactory>(); TryAdd <ITypeMappingSource>(p => p.GetService <IRelationalTypeMappingSource>()); TryAdd <IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>(); TryAdd <IDatabaseCreator>(p => p.GetService <IRelationalDatabaseCreator>()); TryAdd <IDbContextTransactionManager>(p => p.GetService <IRelationalConnection>()); TryAdd <IQueryContextFactory, RelationalQueryContextFactory>(); TryAdd <ICompiledQueryCacheKeyGenerator, RelationalCompiledQueryCacheKeyGenerator>(); TryAdd <INamedConnectionStringResolver, NamedConnectionStringResolver>(); TryAdd <IEvaluatableExpressionFilter, RelationalEvaluatableExpressionFilter>(); TryAdd <IRelationalTransactionFactory, RelationalTransactionFactory>(); TryAdd <IDatabaseFacadeDependencies>(p => p.GetService <IRelationalDatabaseFacadeDependencies>()); TryAdd <IRelationalDatabaseFacadeDependencies, RelationalDatabaseFacadeDependencies>(); TryAdd <IInterceptorResolver, DbConnectionInterceptorResolver>(); TryAdd <IInterceptorResolver, DbTransactionInterceptorResolver>(); TryAdd <IInterceptorResolver, DbCommandInterceptorResolver>(); // New Query pipeline TryAdd <IQuerySqlGeneratorFactory, QuerySqlGeneratorFactory>(); TryAdd <IShapedQueryCompilingExpressionVisitorFactory, RelationalShapedQueryCompilingExpressionVisitorFactory>(); TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, RelationalQueryableMethodTranslatingExpressionVisitorFactory>(); TryAdd <IMethodCallTranslatorProvider, RelationalMethodCallTranslatorProvider>(); TryAdd <IMemberTranslatorProvider, RelationalMemberTranslatorProvider>(); TryAdd <IEntityQueryableTranslatorFactory, RelationalEntityQueryableTranslatorFactory>(); TryAdd <IShapedQueryOptimizerFactory, RelationalShapedQueryOptimizerFactory>(); TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, RelationalSqlTranslatingExpressionVisitorFactory>(); TryAdd <ISqlExpressionFactory, SqlExpressionFactory>(); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton <RelationalSqlGenerationHelperDependencies>() .AddDependencySingleton <RelationalTypeMappingSourceDependencies>() .AddDependencySingleton <RelationalModelValidatorDependencies>() .AddDependencySingleton <UpdateSqlGeneratorDependencies>() .AddDependencySingleton <MigrationsAnnotationProviderDependencies>() .AddDependencySingleton <ParameterNameGeneratorDependencies>() .AddDependencySingleton <RelationalValueBufferFactoryDependencies>() .AddDependencySingleton <RelationalTransactionFactoryDependencies>() .AddDependencySingleton <RelationalCommandBuilderDependencies>() .AddDependencyScoped <MigrationsSqlGeneratorDependencies>() .AddDependencyScoped <RelationalConventionSetBuilderDependencies>() .AddDependencyScoped <ModificationCommandBatchFactoryDependencies>() .AddDependencyScoped <CommandBatchPreparerDependencies>() .AddDependencyScoped <RelationalDatabaseCreatorDependencies>() .AddDependencyScoped <HistoryRepositoryDependencies>() .AddDependencyScoped <RelationalCompiledQueryCacheKeyGeneratorDependencies>() .AddDependencyScoped <RelationalConnectionDependencies>() .AddDependencyScoped <RelationalDatabaseDependencies>(); return(base.TryAddCoreServices()); }
/// <summary> /// Registers default implementations of all services, including relational services, not already /// registered by the provider. Relational database providers must call this method as the last /// step of service registration--that is, after all provider services have been registered. /// </summary> /// <returns> This builder, such that further calls can be chained. </returns> public override EntityFrameworkServicesBuilder TryAddCoreServices() { TryAdd <IParameterNameGeneratorFactory, ParameterNameGeneratorFactory>(); TryAdd <IComparer <ModificationCommand>, ModificationCommandComparer>(); TryAdd <IMigrationsIdGenerator, MigrationsIdGenerator>(); TryAdd <IKeyValueIndexFactorySource, KeyValueIndexFactorySource>(); TryAdd <IModelSource, RelationalModelSource>(); TryAdd <IModelCustomizer, RelationalModelCustomizer>(); TryAdd <IMigrationsAnnotationProvider, MigrationsAnnotationProvider>(); TryAdd <IModelValidator, RelationalModelValidator>(); TryAdd <IMigrator, Migrator>(); TryAdd <IMigrationCommandExecutor, MigrationCommandExecutor>(); TryAdd <IMigrationsAssembly, MigrationsAssembly>(); TryAdd <IDatabase, RelationalDatabase>(); TryAdd <IBatchExecutor, BatchExecutor>(); TryAdd <IValueGeneratorSelector, RelationalValueGeneratorSelector>(); TryAdd <IRelationalCommandBuilderFactory, RelationalCommandBuilderFactory>(); TryAdd <IRawSqlCommandBuilder, RawSqlCommandBuilder>(); TryAdd <ICommandBatchPreparer, CommandBatchPreparer>(); TryAdd <IMigrationsModelDiffer, MigrationsModelDiffer>(); TryAdd <IMigrationsSqlGenerator, MigrationsSqlGenerator>(); TryAdd <IExecutionStrategyFactory, RelationalExecutionStrategyFactory>(); #pragma warning disable 618 TryAdd <IRelationalTypeMapper, ObsoleteRelationalTypeMapper>(); TryAdd <ITypeMapper>(p => p.GetService <IRelationalTypeMapper>()); #pragma warning restore 618 TryAdd <IRelationalTypeMappingSource, FallbackRelationalTypeMappingSource>(); TryAdd <ITypeMappingSource>(p => p.GetService <IRelationalTypeMappingSource>()); TryAdd <IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>(); TryAdd <IDatabaseCreator>(p => p.GetService <IRelationalDatabaseCreator>()); TryAdd <IDbContextTransactionManager>(p => p.GetService <IRelationalConnection>()); TryAdd <IMaterializerFactory, MaterializerFactory>(); TryAdd <IShaperCommandContextFactory, ShaperCommandContextFactory>(); TryAdd <IConditionalRemovingExpressionVisitorFactory, ConditionalRemovingExpressionVisitorFactory>(); TryAdd <ICompositePredicateExpressionVisitorFactory, CompositePredicateExpressionVisitorFactory>(); TryAdd <ISelectExpressionFactory, SelectExpressionFactory>(); TryAdd <IExpressionPrinter, RelationalExpressionPrinter>(); TryAdd <IRelationalResultOperatorHandler, RelationalResultOperatorHandler>(); TryAdd <IQueryContextFactory, RelationalQueryContextFactory>(); TryAdd <IQueryCompilationContextFactory, RelationalQueryCompilationContextFactory>(); TryAdd <IEntityQueryableExpressionVisitorFactory, RelationalEntityQueryableExpressionVisitorFactory>(); TryAdd <IEntityQueryModelVisitorFactory, RelationalQueryModelVisitorFactory>(); TryAdd <IProjectionExpressionVisitorFactory, RelationalProjectionExpressionVisitorFactory>(); TryAdd <ICompiledQueryCacheKeyGenerator, RelationalCompiledQueryCacheKeyGenerator>(); TryAdd <IExpressionFragmentTranslator, RelationalCompositeExpressionFragmentTranslator>(); TryAdd <ISqlTranslatingExpressionVisitorFactory, SqlTranslatingExpressionVisitorFactory>(); TryAdd <INamedConnectionStringResolver, NamedConnectionStringResolver>(); TryAdd <IEvaluatableExpressionFilter, RelationalEvaluatableExpressionFilter>(); TryAdd <IRelationalTransactionFactory, RelationalTransactionFactory>(); TryAdd <ISingletonUpdateSqlGenerator>(p => { using (var scope = p.CreateScope()) { return(scope.ServiceProvider.GetService <IUpdateSqlGenerator>()); } }); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton <RelationalCompositeMemberTranslatorDependencies>() .AddDependencySingleton <RelationalSqlGenerationHelperDependencies>() .AddDependencySingleton <RelationalTypeMapperDependencies>() .AddDependencySingleton <RelationalTypeMappingSourceDependencies>() .AddDependencySingleton <RelationalCompositeExpressionFragmentTranslatorDependencies>() .AddDependencySingleton <RelationalModelValidatorDependencies>() .AddDependencySingleton <UpdateSqlGeneratorDependencies>() .AddDependencySingleton <QuerySqlGeneratorDependencies>() .AddDependencySingleton <RelationalCompositeMethodCallTranslatorDependencies>() .AddDependencySingleton <MigrationsSqlGeneratorDependencies>() .AddDependencySingleton <MigrationsAnnotationProviderDependencies>() .AddDependencySingleton <SqlTranslatingExpressionVisitorDependencies>() .AddDependencySingleton <ParameterNameGeneratorDependencies>() .AddDependencySingleton <SelectExpressionDependencies>() .AddDependencySingleton <RelationalValueBufferFactoryDependencies>() .AddDependencySingleton <RelationalProjectionExpressionVisitorDependencies>() .AddDependencySingleton <RelationalTransactionFactoryDependencies>() .AddDependencyScoped <RelationalConventionSetBuilderDependencies>() .AddDependencyScoped <CommandBatchPreparerDependencies>() .AddDependencyScoped <RelationalDatabaseCreatorDependencies>() .AddDependencyScoped <HistoryRepositoryDependencies>() .AddDependencyScoped <RelationalCompiledQueryCacheKeyGeneratorDependencies>() .AddDependencyScoped <RelationalQueryModelVisitorDependencies>() .AddDependencyScoped <RelationalEntityQueryableExpressionVisitorDependencies>() .AddDependencyScoped <RelationalConnectionDependencies>() .AddDependencyScoped <RelationalDatabaseDependencies>() .AddDependencyScoped <RelationalQueryCompilationContextDependencies>(); return(base.TryAddCoreServices()); }
/// <summary> /// Registers default implementations of all services, including relational services, not already /// registered by the provider. Relational database providers must call this method as the last /// step of service registration--that is, after all provider services have been registered. /// </summary> /// <returns> This builder, such that further calls can be chained. </returns> public override EntityFrameworkServicesBuilder TryAddCoreServices() { TryAdd <IParameterNameGeneratorFactory, ParameterNameGeneratorFactory>(); TryAdd <IComparer <ModificationCommand>, ModificationCommandComparer>(); TryAdd <IMigrationsIdGenerator, MigrationsIdGenerator>(); TryAdd <IKeyValueIndexFactorySource, KeyValueIndexFactorySource>(); TryAdd <IModelSource, RelationalModelSource>(); TryAdd <IMigrationsAnnotationProvider, MigrationsAnnotationProvider>(); TryAdd <IModelValidator, RelationalModelValidator>(); TryAdd <IMigrator, Migrator>(); TryAdd <IMigrationCommandExecutor, MigrationCommandExecutor>(); TryAdd <IMigrationsAssembly, MigrationsAssembly>(); TryAdd <IDatabase, RelationalDatabase>(); TryAdd <IBatchExecutor, BatchExecutor>(); TryAdd <IValueGeneratorSelector, RelationalValueGeneratorSelector>(); TryAdd <IRelationalCommandBuilderFactory, RelationalCommandBuilderFactory>(); TryAdd <IRawSqlCommandBuilder, RawSqlCommandBuilder>(); TryAdd <ICommandBatchPreparer, CommandBatchPreparer>(); TryAdd <IMigrationsModelDiffer, MigrationsModelDiffer>(); TryAdd <IMigrationsSqlGenerator, MigrationsSqlGenerator>(); TryAdd <IExecutionStrategyFactory, RelationalExecutionStrategyFactory>(); TryAdd <IRelationalTypeMapper, RelationalTypeMapper>(); TryAdd <IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>(); TryAdd <IDatabaseCreator>(p => p.GetService <IRelationalDatabaseCreator>()); TryAdd <IDbContextTransactionManager>(p => p.GetService <IRelationalConnection>()); TryAdd <IMaterializerFactory, MaterializerFactory>(); TryAdd <IShaperCommandContextFactory, ShaperCommandContextFactory>(); TryAdd <IConditionalRemovingExpressionVisitorFactory, ConditionalRemovingExpressionVisitorFactory>(); TryAdd <ICompositePredicateExpressionVisitorFactory, CompositePredicateExpressionVisitorFactory>(); TryAdd <ISelectExpressionFactory, SelectExpressionFactory>(); TryAdd <IExpressionPrinter, RelationalExpressionPrinter>(); TryAdd <IRelationalResultOperatorHandler, RelationalResultOperatorHandler>(); TryAdd <IQueryContextFactory, RelationalQueryContextFactory>(); TryAdd <IQueryCompilationContextFactory, RelationalQueryCompilationContextFactory>(); TryAdd <IEntityQueryableExpressionVisitorFactory, RelationalEntityQueryableExpressionVisitorFactory>(); TryAdd <IEntityQueryModelVisitorFactory, RelationalQueryModelVisitorFactory>(); TryAdd <IProjectionExpressionVisitorFactory, RelationalProjectionExpressionVisitorFactory>(); TryAdd <ICompiledQueryCacheKeyGenerator, RelationalCompiledQueryCacheKeyGenerator>(); TryAdd <IExpressionFragmentTranslator, RelationalCompositeExpressionFragmentTranslator>(); TryAdd <ISqlTranslatingExpressionVisitorFactory, SqlTranslatingExpressionVisitorFactory>(); ServiceCollectionMap .TryAddSingleton(s => new DiagnosticListener("Microsoft.EntityFrameworkCore")) .TryAddSingleton <DiagnosticSource>(s => s.GetService <DiagnosticListener>()); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton <RelationalCompositeMemberTranslatorDependencies>() .AddDependencySingleton <RelationalSqlGenerationHelperDependencies>() .AddDependencySingleton <RelationalTypeMapperDependencies>() .AddDependencySingleton <RelationalCompositeExpressionFragmentTranslatorDependencies>() .AddDependencySingleton <RelationalModelValidatorDependencies>() .AddDependencySingleton <UpdateSqlGeneratorDependencies>() .AddDependencySingleton <QuerySqlGeneratorDependencies>() .AddDependencySingleton <RelationalCompositeMethodCallTranslatorDependencies>() .AddDependencySingleton <MigrationsSqlGeneratorDependencies>() .AddDependencySingleton <MigrationsAnnotationProviderDependencies>() .AddDependencySingleton <SqlTranslatingExpressionVisitorDependencies>() .AddDependencySingleton <ParameterNameGeneratorDependencies>() .AddDependencySingleton <SelectExpressionDependencies>() .AddDependencySingleton <RelationalValueBufferFactoryDependencies>() .AddDependencySingleton <RelationalProjectionExpressionVisitorDependencies>() .AddDependencyScoped <RelationalConventionSetBuilderDependencies>() .AddDependencyScoped <RelationalDatabaseCreatorDependencies>() .AddDependencyScoped <HistoryRepositoryDependencies>() .AddDependencyScoped <RelationalCompiledQueryCacheKeyGeneratorDependencies>() .AddDependencyScoped <RelationalQueryModelVisitorDependencies>() .AddDependencyScoped <RelationalEntityQueryableExpressionVisitorDependencies>() .AddDependencyScoped <RelationalConnectionDependencies>() .AddDependencyScoped <RelationalDatabaseDependencies>() .AddDependencyScoped <RelationalQueryCompilationContextDependencies>(); return(base.TryAddCoreServices()); }
/// <summary> /// Do not call this method from application code. This method must be called by database providers /// after registering provider-specific services to fill-in the remaining services with Entity /// Framework defaults. Relational providers should call /// 'ServiceCollectionRelationalProviderInfrastructure.TryAddDefaultRelationalServices' instead. /// </summary> /// <param name="serviceCollectionMap"> The <see cref="ServiceCollectionMap" /> to add services to. </param> public static void TryAddDefaultEntityFrameworkServices([NotNull] ServiceCollectionMap serviceCollectionMap) { Check.NotNull(serviceCollectionMap, nameof(serviceCollectionMap)); serviceCollectionMap .TryAddSingleton <IDbSetFinder, DbSetFinder>() .TryAddSingleton <IDbSetInitializer, DbSetInitializer>() .TryAddSingleton <IDbSetSource, DbSetSource>() .TryAddSingleton <IEntityFinderSource, EntityFinderSource>() .TryAddSingleton <IEntityMaterializerSource, EntityMaterializerSource>() .TryAddSingleton <ICoreConventionSetBuilder, CoreConventionSetBuilder>() .TryAddSingleton <IModelCustomizer, ModelCustomizer>() .TryAddSingleton <IModelCacheKeyFactory, ModelCacheKeyFactory>() .TryAddSingleton <ILoggerFactory, LoggerFactory>() .TryAddSingleton <IModelSource, ModelSource>() .TryAddSingleton <IInternalEntityEntryFactory, InternalEntityEntryFactory>() .TryAddSingleton <IInternalEntityEntrySubscriber, InternalEntityEntrySubscriber>() .TryAddSingleton <IEntityEntryGraphIterator, EntityEntryGraphIterator>() .TryAddSingleton <IEntityGraphAttacher, EntityGraphAttacher>() .TryAddSingleton <IValueGeneratorCache, ValueGeneratorCache>() .TryAddSingleton <INodeTypeProviderFactory, DefaultMethodInfoBasedNodeTypeRegistryFactory>() .TryAddScoped <IKeyPropagator, KeyPropagator>() .TryAddScoped <INavigationFixer, NavigationFixer>() .TryAddScoped <ILocalViewListener, LocalViewListener>() .TryAddScoped <IStateManager, StateManager>() .TryAddScoped <IConcurrencyDetector, ConcurrencyDetector>() .TryAddScoped <IInternalEntityEntryNotifier, InternalEntityEntryNotifier>() .TryAddScoped <IValueGenerationManager, ValueGenerationManager>() .TryAddScoped <IChangeTrackerFactory, ChangeTrackerFactory>() .TryAddScoped <IChangeDetector, ChangeDetector>() .TryAddScoped <IDbContextServices, DbContextServices>() .TryAddScoped <IValueGeneratorSelector, ValueGeneratorSelector>() .TryAddScoped <IConventionSetBuilder, NullConventionSetBuilder>() .TryAddScoped <IModelValidator, CoreModelValidator>() .TryAddScoped <IExecutionStrategyFactory, ExecutionStrategyFactory>() .TryAddScoped <ICompiledQueryCache, CompiledQueryCache>() .TryAddScoped <IAsyncQueryProvider, EntityQueryProvider>() .TryAddScoped <IQueryCompiler, QueryCompiler>() .TryAddScoped <IQueryAnnotationExtractor, QueryAnnotationExtractor>() .TryAddScoped <IQueryOptimizer, QueryOptimizer>() .TryAddScoped <IEntityTrackingInfoFactory, EntityTrackingInfoFactory>() .TryAddScoped <ISubQueryMemberPushDownExpressionVisitor, SubQueryMemberPushDownExpressionVisitor>() .TryAddScoped <ITaskBlockingExpressionVisitor, TaskBlockingExpressionVisitor>() .TryAddScoped <IEntityResultFindingExpressionVisitorFactory, EntityResultFindingExpressionVisitorFactory>() .TryAddScoped <IMemberAccessBindingExpressionVisitorFactory, MemberAccessBindingExpressionVisitorFactory>() .TryAddScoped <INavigationRewritingExpressionVisitorFactory, NavigationRewritingExpressionVisitorFactory>() .TryAddScoped <IOrderingExpressionVisitorFactory, OrderingExpressionVisitorFactory>() .TryAddScoped <IQuerySourceTracingExpressionVisitorFactory, QuerySourceTracingExpressionVisitorFactory>() .TryAddScoped <IRequiresMaterializationExpressionVisitorFactory, RequiresMaterializationExpressionVisitorFactory>() .TryAddScoped <IExpressionPrinter, ExpressionPrinter>() .TryAddScoped <IQueryCompilationContextFactory, QueryCompilationContextFactory>() .TryAddScoped <ICompiledQueryCacheKeyGenerator, CompiledQueryCacheKeyGenerator>() .TryAddScoped <IResultOperatorHandler, ResultOperatorHandler>() .TryAddScoped <IProjectionExpressionVisitorFactory, ProjectionExpressionVisitorFactory>() .TryAddScoped(typeof(ISensitiveDataLogger <>), typeof(SensitiveDataLogger <>)) .TryAddScoped(typeof(ILogger <>), typeof(InterceptingLogger <>)) .TryAddScoped(p => GetContextServices(p).Model) .TryAddScoped(p => GetContextServices(p).CurrentContext) .TryAddScoped(p => GetContextServices(p).ContextOptions) .TryAddScopedEnumerable <IEntityStateListener, INavigationFixer>(p => p.GetService <INavigationFixer>()) .TryAddScopedEnumerable <INavigationListener, INavigationFixer>(p => p.GetService <INavigationFixer>()) .TryAddScopedEnumerable <IKeyListener, INavigationFixer>(p => p.GetService <INavigationFixer>()) .TryAddScopedEnumerable <IQueryTrackingListener, INavigationFixer>(p => p.GetService <INavigationFixer>()) .TryAddScopedEnumerable <IPropertyListener, IChangeDetector>(p => p.GetService <IChangeDetector>()) .TryAddScopedEnumerable <IEntityStateListener, ILocalViewListener>(p => p.GetService <ILocalViewListener>()) .TryAddScopedEnumerable <IResettableService, IStateManager>(p => p.GetService <IStateManager>()) .TryAddScopedEnumerable <IResettableService, IDbContextTransactionManager>(p => p.GetService <IDbContextTransactionManager>()) .TryAddSingleton <DatabaseProviderDependencies, DatabaseProviderDependencies>() .TryAddSingleton <ResultOperatorHandlerDependencies, ResultOperatorHandlerDependencies>() .TryAddSingleton <ModelSourceDependencies, ModelSourceDependencies>() .TryAddSingleton <ValueGeneratorCacheDependencies, ValueGeneratorCacheDependencies>() .TryAddScoped(typeof(SensitiveDataLoggerDependencies <>), typeof(SensitiveDataLoggerDependencies <>)) .TryAddScoped <ExecutionStrategyContextDependencies, ExecutionStrategyContextDependencies>() .TryAddScoped <CompiledQueryCacheKeyGeneratorDependencies, CompiledQueryCacheKeyGeneratorDependencies>() .TryAddScoped <QueryContextDependencies, QueryContextDependencies>() .TryAddScoped <ModelValidatorDependencies, ModelValidatorDependencies>() .TryAddScoped <ValueGeneratorSelectorDependencies, ValueGeneratorSelectorDependencies>() .TryAddScoped <EntityQueryModelVisitorDependencies, EntityQueryModelVisitorDependencies>() .TryAddScoped <DatabaseDependencies, DatabaseDependencies>() .TryAddScoped <ModelCustomizerDependencies, ModelCustomizerDependencies>() .TryAddScoped <ModelCacheKeyFactoryDependencies, ModelCacheKeyFactoryDependencies>() .TryAddScoped <QueryCompilationContextDependencies, QueryCompilationContextDependencies>(); // Note: does TryAdd on all services serviceCollectionMap.ServiceCollection.AddMemoryCache(); }
/// <summary> /// Used by database providers to create a new <see cref="EntityFrameworkServicesBuilder" /> for /// registration of provider services. Relational providers should use /// 'EntityFrameworkRelationalServicesBuilder'. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-providers">Implementation of database providers and extensions</see> /// for more information. /// </remarks> /// <param name="serviceCollection">The collection to which services will be registered.</param> public EntityFrameworkServicesBuilder(IServiceCollection serviceCollection) { ServiceCollectionMap = new ServiceCollectionMap(serviceCollection); }
/// <summary> /// /// </summary> /// <returns></returns> public override EntityFrameworkServicesBuilder TryAddCoreServices() { // TODO: Register services // Model TryAdd <IModelSource, RelationalModelSource>(); // RelationalModelSource just extends ModelSource TryAdd <IModelValidator, CypherModelValidator>(); TryAdd <IModelCustomizer, CypherModelCustomizer>(); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton <RelationalTypeMapperDependencies>() .AddDependencySingleton <RelationalModelValidatorDependencies>() .AddDependencyScoped <RelationalConventionSetBuilderDependencies>(); // Migrations // Despite the semantic discomfort with SQL prefixes most of the relational command/database services can be reused TryAdd <IDatabase, RelationalDatabase>(); TryAdd <IRawSqlCommandBuilder, RawSqlCommandBuilder>(); TryAdd <IRelationalCommandBuilderFactory, RelationalCommandBuilderFactory>(); TryAdd <IParameterNameGeneratorFactory, ParameterNameGeneratorFactory>(); ServiceCollectionMap.GetInfrastructure() .AddDependencyScoped <RelationalConnectionDependencies>() .AddDependencyScoped <RelationalDatabaseDependencies>() .AddDependencySingleton <RelationalSqlGenerationHelperDependencies>() .AddDependencySingleton <ParameterNameGeneratorDependencies>(); // Relinq (i.e. INodeTypeProviderFactory) // Query TryAdd <IQueryContextFactory, RelationalQueryContextFactory>(); TryAdd <IQueryCompilationContextFactory, CypherQueryCompilationContextFactory>(); TryAdd <IEntityQueryableExpressionVisitorFactory, CypherEntityQueryableExpressionVisitorFactory>(); TryAdd <IEntityQueryModelVisitorFactory, CypherQueryModelVisitorFactory>(); TryAdd <IEvaluatableExpressionFilter, RelationalEvaluatableExpressionFilter>(); TryAdd <ICypherResultOperatorHandler, CypherResultOperatorHandler>(); TryAdd <ICypherMaterializerFactory, CypherMaterializerFactory>(); TryAdd <IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>(); TryAdd <IShaperCommandContextFactory, ShaperCommandContextFactory>(); TryAdd <IReadOnlyExpressionFactory, ReadOnlyExpressionFactory>(); TryAdd <IExpressionFragmentTranslator, RelationalCompositeExpressionFragmentTranslator>(); TryAdd <ICypherTranslatingExpressionVisitorFactory, CypherTranslatingExpressionVisitorFactory>(); TryAdd <IProjectionExpressionVisitorFactory, CypherProjectionExpressionVisitorFactory>(); TryAdd <IRequiresMaterializationExpressionVisitorFactory, CypherRequiresMaterializationExpressionVisitorFactory>(); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton <RelationalCompositeMemberTranslatorDependencies>() .AddDependencyScoped <RelationalQueryCompilationContextDependencies>() .AddDependencyScoped <CypherEntityQueryableExpressionVisitorDependencies>() .AddDependencySingleton <RelationalCompositeExpressionFragmentTranslatorDependencies>() .AddDependencyScoped <CypherQueryModelVisitorDependencies>() .AddDependencyScoped <RelationalQueryCompilationContextDependencies>() .AddDependencySingleton <ReadOnlyExpressionDependencies>() .AddDependencySingleton <QuerySqlGeneratorDependencies>() .AddDependencySingleton <RelationalCompositeMethodCallTranslatorDependencies>() .AddDependencySingleton <RelationalValueBufferFactoryDependencies>() .AddDependencySingleton <SqlTranslatingExpressionVisitorDependencies>() .AddDependencySingleton <CypherProjectionExpressionVisitorDependencies>(); // Update TryAdd <ICommandBatchPreparer, CommandBatchPreparer>(); TryAdd <IComparer <ModificationCommand>, ModificationCommandComparer>(); TryAdd <IKeyValueIndexFactorySource, KeyValueIndexFactorySource>(); TryAdd <IBatchExecutor, BatchExecutor>(); // Relational transaction factory (post 2.0) return(base.TryAddCoreServices()); }