/// <summary>
        ///     <para>
        ///         Adds the given extension to the options. If an existing extension of the same type already exists, it will be replaced.
        ///     </para>
        ///     <para>
        ///         This method is intended for use by extension methods to configure the context. It is not intended to be used in
        ///         application code.
        ///     </para>
        /// </summary>
        /// <typeparam name="TExtension"> The type of extension to be added. </typeparam>
        /// <param name="extension"> The extension to be added. </param>
        void IDbContextOptionsBuilderInfrastructure.AddOrUpdateExtension <TExtension>(TExtension extension)
        {
            Check.NotNull(extension, nameof(extension));

            _options = _options.WithExtension(extension);
        }
 /// <summary>
 ///     <para>
 ///         Sets the model to be used for the context. If the model is set, then <see cref="DbContext.OnModelCreating(ModelBuilder)" />
 ///         will not be run.
 ///     </para>
 ///     <para>
 ///         If setting an externally created model <see cref="ModelBuilder.FinalizeModel()" /> should be called first.
 ///     </para>
 /// </summary>
 /// <param name="model"> The model to be used. </param>
 /// <returns> The same builder instance so that multiple calls can be chained. </returns>
 public virtual DbContextOptionsBuilder UseModel([NotNull] IModel model)
 => WithOption(e => e.WithModel(Check.NotNull(model, nameof(model))));
 /// <summary>
 ///     <para>
 ///         Adds <see cref="IInterceptor" /> instances to those registered on the context.
 ///     </para>
 ///     <para>
 ///         Interceptors can be used to view, change, or suppress operations taken by Entity Framework.
 ///         See the specific implementations of <see cref="IInterceptor" /> for details. For example, 'IDbCommandInterceptor'.
 ///     </para>
 ///     <para>
 ///         A single interceptor instance can implement multiple different interceptor interfaces. I will be registered as
 ///         an interceptor for all interfaces that it implements.
 ///     </para>
 ///     <para>
 ///         Extensions can also register multiple <see cref="IInterceptor" />s in the internal service provider.
 ///         If both injected and application interceptors are found, then the injected interceptors are run in the
 ///         order that they are resolved from the service provider, and then the application interceptors are run
 ///         in the order that they were added to the context.
 ///     </para>
 ///     <para>
 ///         Calling this method multiple times will result in all interceptors in every call being added to the context.
 ///         Interceptors added in a previous call are not overridden by interceptors added in a later call.
 ///     </para>
 /// </summary>
 /// <param name="interceptors"> The interceptors to add. </param>
 /// <returns> The same builder instance so that multiple calls can be chained. </returns>
 public virtual DbContextOptionsBuilder AddInterceptors([NotNull] IEnumerable <IInterceptor> interceptors)
 => WithOption(e => e.WithInterceptors(Check.NotNull(interceptors, nameof(interceptors))));
        /// <summary>
        ///     Initializes a new instance of the <see cref="DbContextOptionsBuilder" /> class to further configure
        ///     a given <see cref="DbContextOptions" />.
        /// </summary>
        /// <param name="options"> The options to be configured. </param>
        public DbContextOptionsBuilder([NotNull] DbContextOptions options)
        {
            Check.NotNull(options, nameof(options));

            _options = options;
        }
Esempio n. 5
0
        /// <summary>
        ///     Returns an object that can be used to configure a given entity type in the model.
        ///     If the entity type is not already part of the model, it will be added to the model.
        /// </summary>
        /// <param name="type"> The entity type to be configured. </param>
        /// <returns> An object that can be used to configure the entity type. </returns>
        public virtual EntityTypeBuilder Entity([NotNull] Type type)
        {
            Check.NotNull(type, nameof(type));

            return(new EntityTypeBuilder(Builder.Entity(type, ConfigurationSource.Explicit, throwOnQuery: true)));
        }
Esempio n. 6
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ModelBuilder" /> class that will
        ///     apply a set of conventions.
        /// </summary>
        /// <param name="conventions"> The conventions to be applied to the model. </param>
        public ModelBuilder([NotNull] ConventionSet conventions)
        {
            Check.NotNull(conventions, nameof(conventions));

            _builder = new InternalModelBuilder(new Model(conventions));
        }
Esempio n. 7
0
        /// <summary>
        ///     Returns an object that can be used to configure a given query type in the model.
        ///     If the query type is not already part of the model, it will be added to the model.
        /// </summary>
        /// <param name="type"> The query type to be configured. </param>
        /// <returns> An object that can be used to configure the query type. </returns>
        public virtual QueryTypeBuilder Query([NotNull] Type type)
        {
            Check.NotNull(type, nameof(type));

            return(new QueryTypeBuilder(Builder.Query(type)));
        }