/// <summary> /// Registers the OpenIddict entity sets in the Entity Framework Core /// context using the specified entities and the specified key type. /// </summary> /// <param name="builder">The builder used to configure the Entity Framework context.</param> /// <returns>The Entity Framework context builder.</returns> public static DbContextOptionsBuilder UseOpenIddict <TApplication, TAuthorization, TScope, TToken, TKey>([NotNull] this DbContextOptionsBuilder builder) where TApplication : OpenIddictApplication <TKey, TAuthorization, TToken> where TAuthorization : OpenIddictAuthorization <TKey, TApplication, TToken> where TScope : OpenIddictScope <TKey> where TToken : OpenIddictToken <TKey, TApplication, TAuthorization> where TKey : IEquatable <TKey> { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.ReplaceService <IModelCustomizer, OpenIddictEntityFrameworkCoreCustomizer < TApplication, TAuthorization, TScope, TToken, TKey> >()); }
public static DbContextOptionsBuilder EnableTemporalTableQueries([NotNull] this DbContextOptionsBuilder optionsBuilder) { // If service provision is NOT being performed internally, we cannot replace services. var coreOptions = optionsBuilder.Options.GetExtension <CoreOptionsExtension>(); if (coreOptions.InternalServiceProvider == null) { return(optionsBuilder // replace the service responsible for generating SQL strings .ReplaceService <IQuerySqlGeneratorFactory, TemporalQuerySqlGeneratorFactory>() // replace the service responsible for traversing the Linq AST (a.k.a Query Methods) .ReplaceService <IQueryableMethodTranslatingExpressionVisitorFactory, TemporalQueryableMethodTranslatingExpressionVisitorFactory>() // replace the service responsible for providing instances of SqlExpressions .ReplaceService <ISqlExpressionFactory, TemporalSqlExpressionFactory>()); } else { return(optionsBuilder); } }
public static DbContextOptionsBuilder UseIdentityServer(this DbContextOptionsBuilder optionsBuilder, Action <AtaogeDbContextOptionsExtension> options) { var infrastructure = ((IDbContextOptionsBuilderInfrastructure)optionsBuilder); var contextOptions = optionsBuilder.Options; var ataogeOptionsExtension = optionsBuilder.Options.FindExtension <AtaogeDbContextOptionsExtension>() ?? new AtaogeDbContextOptionsExtension(); infrastructure.AddOrUpdateExtension(ataogeOptionsExtension); if (options != null) { options(ataogeOptionsExtension); } if (ataogeOptionsExtension.UseInnerModel) { optionsBuilder.ReplaceService <IModelCustomizer, IdentityServerModelCustomizer>(); } return(optionsBuilder); }
public static DbContextOptionsBuilder EnableUserDefinedTypesNotificationsSupport(this DbContextOptionsBuilder builder) { return(builder.ReplaceService <IInternalEntityEntrySubscriber, EntityEntrySubscriber> ( )); }
public static void UseBatchEF_MySQLPomelo(this DbContextOptionsBuilder optBuilder) { optBuilder.ReplaceService <IQuerySqlGeneratorFactory, ZackQuerySqlGeneratorFactory_MySQLPomelo>(); }
/// <summary> /// 使用RivenFx的PostgreSQL SqlGeneration实现 /// </summary> /// <param name="optionsBuilder"></param> /// <returns></returns> public static DbContextOptionsBuilder UseRivenPostgreSqlGeneration(this DbContextOptionsBuilder optionsBuilder) { return(optionsBuilder .ReplaceService <ISqlGenerationHelper, RivenPostgreSqlGenerationHelper>()); }
public static DbContextOptionsBuilder UseCustomSqlServerQuerySqlGenerator(this DbContextOptionsBuilder optionsBuilder) { optionsBuilder.ReplaceService <IQuerySqlGeneratorFactory, CustomSqlServerQuerySqlGeneratorFactory>(); return(optionsBuilder); }
public static DbContextOptionsBuilder UseCustomExtensions(this DbContextOptionsBuilder optionsBuilder) => optionsBuilder .ReplaceService <INodeTypeProviderFactory, CustomNodeTypeProviderFactory>() .ReplaceService <IRelationalResultOperatorHandler, CustomRelationalResultOperatorHandler>();
public static DbContextOptionsBuilder UseRemoveForeignKeyService(this DbContextOptionsBuilder options) { options.ReplaceService <IMigrationsSqlGenerator, CustomMigrationsSqlGeneratore>(); return(options); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .ReplaceService <IDbContextTransactionManager, FakeTransactionManager>() .EnableServiceProviderCaching(false) .UseInMemoryDatabase(Guid.NewGuid().ToString());
public static DbContextOptionsBuilder UseStronglyTypedIdValueConverters(this DbContextOptionsBuilder options) { return(options .ReplaceService <IValueConverterSelector, CustomValueConverterSelector>()); }
/// <summary> /// 使用 RivenFx 实现的 Oracle RelationalTypeMappingSource /// </summary> /// <param name="optionsBuilder"></param> /// <returns></returns> public static DbContextOptionsBuilder UseRivenOracleTypeMapping(this DbContextOptionsBuilder optionsBuilder) { return(optionsBuilder .ReplaceService <IRelationalTypeMappingSource, RivenOracleTypeMappingSource>() ); }
/// <summary> /// 使用 RivenFx 实现的 Oracle RelationalCommandBuilderFactory /// </summary> /// <param name="optionsBuilder"></param> /// <returns></returns> public static DbContextOptionsBuilder UseRivenOracleRelationalCommandBuilderFactory(this DbContextOptionsBuilder optionsBuilder) { return(optionsBuilder .ReplaceService <IRelationalCommandBuilderFactory, RivenOracleRelationalCommandBuilderFactory>() ); }
/// <summary> /// 使用 RivenFx 实现的 Oracle SqlGeneration ToUpper /// </summary> /// <param name="optionsBuilder"></param> /// <returns></returns> public static DbContextOptionsBuilder UseRivenOracleSqlGenerationToUpper(this DbContextOptionsBuilder optionsBuilder) { return(optionsBuilder .ReplaceService <ISqlGenerationHelper, RivenOracleSqlGenerationHelperToUpper>() ); }
public static DbContextOptionsBuilder UseNpgsqlCaseInsensitive(this DbContextOptionsBuilder builder, string connectionString) { builder.UseNpgsql(connectionString); return(builder.ReplaceService <IQuerySqlGeneratorFactory, CaseInsensitiveSqlGeneratorFactory>()); }