/// <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(); }