src/Shared/EntityFramework/Internal/ModelHashCalculator.cs
// <summary>
// Calculates an SHA256 hash of the EDMX from the given code first model. This is the hash stored in
// the database in the EdmMetadata table in EF 4.1/4.2. The hash is always calculated using a v2 schema
// as was generated by EF 4.1/4.2 and with the <see cref="EdmMetadata" /> entity included in the model.
// </summary>
Calculates an SHA256 hash of the EDMX from the given code first model. This is the hash stored in
the database in the EdmMetadata table in EF 4.1/4.2. The hash is always calculated using a v2 schema
as was generated by EF 4.1/4.2 and with the  entity included in the model.
Calculates an SHA256 hash of the EDMX from the given code first model . This is the hash stored in the database in the EdmMetadata table in EF 4 . 1 / 4 . 2 . The hash is always calculated using a v2 schema as was generated by EF 4 . 1 / 4 . 2 and with the entity included in the model .
public virtual string Calculate(DbCompiledModel compiledModel)
        {
            DebugCheck.NotNull(compiledModel);
            DebugCheck.NotNull(compiledModel.ProviderInfo);
            DebugCheck.NotNull(compiledModel.CachedModelBuilder);
            var providerInfo = compiledModel.ProviderInfo;
            var modelBuilder = compiledModel.CachedModelBuilder.Clone();
            EdmMetadataContext.ConfigureEdmMetadata(modelBuilder.ModelConfiguration);
            var databaseMetadata = modelBuilder.Build(providerInfo).DatabaseMapping.Database;
            databaseMetadata.SchemaVersion = XmlConstants.StoreVersionForV2; 
            var stringBuilder = new StringBuilder();
            using (var xmlWriter = XmlWriter.Create(
                stringBuilder, new XmlWriterSettings
                    {
                        Indent = true
                    }))
            {
                new SsdlSerializer().Serialize(
                    databaseMetadata,
                    providerInfo.ProviderInvariantName,
                    providerInfo.ProviderManifestToken,
                    xmlWriter);
            }
            return ComputeSha256Hash(stringBuilder.ToString());
        }
public virtual string Calculate ( DbCompiledModel compiledModel ) { DebugCheck . NotNull ( compiledModel ) ; DebugCheck . NotNull ( compiledModel . ProviderInfo ) ; DebugCheck . NotNull ( compiledModel . CachedModelBuilder ) ; var providerInfo = compiledModel . ProviderInfo ; var modelBuilder = compiledModel . CachedModelBuilder . Clone ( ) ; EdmMetadataContext . ConfigureEdmMetadata ( modelBuilder . ModelConfiguration ) ; var databaseMetadata = modelBuilder . Build ( providerInfo ) . DatabaseMapping . Database ; databaseMetadata . SchemaVersion = XmlConstants . StoreVersionForV2 ; var stringBuilder = new StringBuilder ( ) ; using ( var xmlWriter = XmlWriter . Create ( stringBuilder , new XmlWriterSettings { Indent = true } ) ) { new SsdlSerializer ( ) . Serialize ( databaseMetadata , providerInfo . ProviderInvariantName , providerInfo . ProviderManifestToken , xmlWriter ) ; } return ComputeSha256Hash ( stringBuilder . ToString ( ) ) ; }
Calculates an SHA256 hash of the EDMX from the given code first model.
Calculates an SHA256 hash of the EDMX from the given code first model .
// Add back in the EdmMetadata class because the hash created by EF 4.1 and 4.2 will contain it. // Ensures SSDL version matches that created by EF 4.1/4.2
compiledModel
DbCompiledModel