CreateModelBuilder() public method

Creates and configures the DbModelBuilder instance that will be used to build the DbCompiledModel.
public CreateModelBuilder ( ) : DbModelBuilder
return DbModelBuilder
        // <summary>
        // Creates an immutable, cacheable representation of the model defined by this builder.
        // This model can be used to create an <see cref="ObjectContext" /> or can be passed to a <see cref="DbContext" />
        // constructor to create a <see cref="DbContext" /> for this model.
        // </summary>
        public static DbCompiledModel CreateModel(LazyInternalContext internalContext)
        {
            var contextType = internalContext.Owner.GetType();

            DbModelStore modelStore = null;

            if (!(internalContext.Owner is HistoryContext))
            {
                modelStore = DbConfiguration.DependencyResolver.GetService <DbModelStore>();
                if (modelStore != null)
                {
                    var compiledModel = modelStore.TryLoad(contextType);
                    if (compiledModel != null)
                    {
                        return(compiledModel);
                    }
                }
            }

            var modelBuilder = internalContext.CreateModelBuilder();

            var model
                = (internalContext._modelProviderInfo == null)
                      ? modelBuilder.Build(internalContext._internalConnection.Connection)
                      : modelBuilder.Build(internalContext._modelProviderInfo);

            internalContext._modelBeingInitialized = model;

            if (modelStore != null)
            {
                modelStore.Save(contextType, model);
            }

            return(model.Compile());
        }
示例#2
0
        public static DbCompiledModel CreateModel(LazyInternalContext internalContext)
        {
            DbModelBuilder modelBuilder = internalContext.CreateModelBuilder();
            DbModel        dbModel      = internalContext._modelProviderInfo == null?modelBuilder.Build(internalContext._internalConnection.Connection) : modelBuilder.Build(internalContext._modelProviderInfo);

            internalContext._modelBeingInitialized = dbModel;
            return(dbModel.Compile());
        }
示例#3
0
        /// <summary>
        ///     Creates an immutable, cacheable representation of the model defined by this builder.
        ///     This model can be used to create an <see cref="ObjectContext" /> or can be passed to a <see cref="DbContext" />
        ///     constructor to create a <see cref="DbContext" /> for this model.
        /// </summary>
        public static DbCompiledModel CreateModel(LazyInternalContext internalContext)
        {
            var modelBuilder = internalContext.CreateModelBuilder();

            var model
                = (internalContext._modelProviderInfo == null)
                      ? modelBuilder.Build(internalContext._internalConnection.Connection)
                      : modelBuilder.Build(internalContext._modelProviderInfo);

            return(model.Compile());
        }
        /// <summary>
        ///     Creates an immutable, cacheable representation of the model defined by this builder.
        ///     This model can be used to create an <see cref="ObjectContext" /> or can be passed to a <see cref="DbContext" />
        ///     constructor to create a <see cref="DbContext" /> for this model.
        /// </summary>
        public static DbCompiledModel CreateModel(LazyInternalContext internalContext)
        {
            var modelBuilder = internalContext.CreateModelBuilder();

            var model
                = (internalContext._modelProviderInfo == null)
                      ? modelBuilder.Build(internalContext._internalConnection.Connection)
                      : modelBuilder.Build(internalContext._modelProviderInfo);

            return model.Compile();
        }
        // <summary>
        // Creates an immutable, cacheable representation of the model defined by this builder.
        // This model can be used to create an <see cref="ObjectContext" /> or can be passed to a <see cref="DbContext" />
        // constructor to create a <see cref="DbContext" /> for this model.
        // </summary>
        public static DbCompiledModel CreateModel(LazyInternalContext internalContext)
        {
            var contextType = internalContext.Owner.GetType();

            DbModelStore modelStore = null;
            if (!(internalContext.Owner is HistoryContext))
            {
                modelStore = DbConfiguration.DependencyResolver.GetService<DbModelStore>();
                if (modelStore != null)
                {
                    var compiledModel = modelStore.TryLoad(contextType);
                    if (compiledModel != null)
                    {
                        return compiledModel;
                    }
                }
            }

            var modelBuilder = internalContext.CreateModelBuilder();

            var model
                = (internalContext._modelProviderInfo == null)
                      ? modelBuilder.Build(internalContext._internalConnection.Connection)
                      : modelBuilder.Build(internalContext._modelProviderInfo);

            internalContext._modelBeingInitialized = model;

            if (modelStore != null)
            {
                modelStore.Save(contextType, model);
            }

            return model.Compile();
        }