/// <summary> /// Creates a new instance with all options the same as for this instance, but with the given option changed. /// It is unusual to call this method directly. Instead use <see cref="DbContextOptionsBuilder" />. /// </summary> /// <param name="warningsConfiguration"> The option to change. </param> /// <returns> A new instance with the option changed. </returns> public virtual CoreOptionsExtension WithWarningsConfiguration([CanBeNull] WarningsConfiguration warningsConfiguration) { var clone = Clone(); clone._warningsConfiguration = warningsConfiguration; return(clone); }
/// <summary> /// Called by a derived class constructor when implementing the <see cref="Clone" /> method. /// </summary> /// <param name="copyFrom"> The instance that is being cloned. </param> protected CoreOptionsExtension([NotNull] CoreOptionsExtension copyFrom) { _internalServiceProvider = copyFrom.InternalServiceProvider; _applicationServiceProvider = copyFrom.ApplicationServiceProvider; _model = copyFrom.Model; _loggerFactory = copyFrom.LoggerFactory; _memoryCache = copyFrom.MemoryCache; _sensitiveDataLoggingEnabled = copyFrom.IsSensitiveDataLoggingEnabled; _detailedErrorsEnabled = copyFrom.DetailedErrorsEnabled; _warningsConfiguration = copyFrom.WarningsConfiguration; _queryTrackingBehavior = copyFrom.QueryTrackingBehavior; _maxPoolSize = copyFrom.MaxPoolSize; if (copyFrom._replacedServices != null) { _replacedServices = new Dictionary <Type, Type>(copyFrom._replacedServices); } }
/// <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 virtual void Validate(IDbContextOptions options) { var coreOptions = options.FindExtension <CoreOptionsExtension>() ?? new CoreOptionsExtension(); if (IsSensitiveDataLoggingEnabled != coreOptions.IsSensitiveDataLoggingEnabled) { Check.DebugAssert(coreOptions.InternalServiceProvider != null, "InternalServiceProvider is null"); throw new InvalidOperationException( CoreStrings.SingletonOptionChanged( nameof(DbContextOptionsBuilder.EnableSensitiveDataLogging), nameof(DbContextOptionsBuilder.UseInternalServiceProvider))); } if (WarningsConfiguration?.GetServiceProviderHashCode() != coreOptions.WarningsConfiguration?.GetServiceProviderHashCode()) { Check.DebugAssert(coreOptions.InternalServiceProvider != null, "InternalServiceProvider is null"); throw new InvalidOperationException( CoreStrings.SingletonOptionChanged( nameof(DbContextOptionsBuilder.ConfigureWarnings), nameof(DbContextOptionsBuilder.UseInternalServiceProvider))); } }