internal static DbDatabaseMapping Initialize(
            this DbDatabaseMapping databaseMapping, EdmModel model, DbDatabaseMetadata database)
        {
            Contract.Requires(databaseMapping != null);
            Contract.Requires(databaseMapping != null);
            Contract.Requires(database != null);

            databaseMapping.Model = model;
            databaseMapping.Database = database;
            var entityContainerMapping
                = new DbEntityContainerMapping
                    {
                        EntityContainer = model.Containers.Single()
                    };
            databaseMapping.EntityContainerMappings.Add(entityContainerMapping);

            return databaseMapping;
        }
        private void WriteEntityContainerMappingElement(DbEntityContainerMapping containerMapping)
        {
            Contract.Assert(containerMapping != null, "containerMapping cannot be null");

            _xmlWriter.WriteStartElement(MslConstants.Element_EntityContainerMapping);
            _xmlWriter.WriteAttributeString(MslConstants.Attribute_StorageEntityContainer, _dbSchemaName);
            _xmlWriter.WriteAttributeString(
                MslConstants.Attribute_CDMEntityContainer, containerMapping.EntityContainer.Name);

            foreach (var set in containerMapping.EntitySetMappings)
            {
                WriteEntitySetMappingElement(set);
            }

            foreach (var set in containerMapping.AssociationSetMappings)
            {
                WriteAssociationSetMappingElement(set);
            }

            _xmlWriter.WriteEndElement();
        }