// <summary> // Builds and stores the workspace based on the given code first configuration. // </summary> // <param name="databaseMapping"> The code first EDM model. </param> public CodeFirstCachedMetadataWorkspace(DbDatabaseMapping databaseMapping) { DebugCheck.NotNull(databaseMapping); _providerInfo = databaseMapping.ProviderInfo; _metadataWorkspace = databaseMapping.ToMetadataWorkspace(); _assemblies = databaseMapping.Model.GetClrTypes().Select(t => t.Assembly()).Distinct().ToList(); Debug.Assert(databaseMapping.Model.Containers.Count() == 1, "Expecting Code First to create only one container."); _defaultContainerName = databaseMapping.Model.Containers.First().Name; }
public static CodeFirstCachedMetadataWorkspace Create(DbDatabaseMapping databaseMapping) { var conceptualModel = databaseMapping.Model; return new CodeFirstCachedMetadataWorkspace( databaseMapping.ToMetadataWorkspace(), conceptualModel.GetClrTypes().Select(t => t.Assembly()).Distinct().ToArray(), databaseMapping.ProviderInfo, conceptualModel.Container.Name); }