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