Ejemplo n.º 1
0
        /// <summary>
        /// Reads a metadata model from .edmx.
        /// </summary>
        /// <param name="reader">XML reader for the .edmx</param>
        /// <param name="defaultSchema">Default database schema used by the model.</param>
        /// <returns>The loaded metadata model.</returns>
        public static DbCompiledModel Read(XmlReader reader, string defaultSchema)
        {
            Check.NotNull(reader, "reader");

            var document = XDocument.Load(reader);

            DbProviderInfo providerInfo;
            var            mappingItemCollection = document.GetStorageMappingItemCollection(out providerInfo);

            return(new DbCompiledModel(
                       CodeFirstCachedMetadataWorkspace.Create(mappingItemCollection, providerInfo),
                       defaultSchema));
        }
 /// <summary>
 /// Creates a <see cref="DbCompiledModel" /> for this mode which is a compiled snapshot
 /// suitable for caching and creation of <see cref="DbContext" /> instances.
 /// </summary>
 /// <returns> The compiled model. </returns>
 public DbCompiledModel Compile()
 {
     return(new DbCompiledModel(
                CodeFirstCachedMetadataWorkspace.Create(DatabaseMapping),
                CachedModelBuilder));
 }