public XDocument BuildMappingDocument(Configuration configuration, IMapping mapping = null) { if (mapping == null) { mapping = configuration.BuildMapping(); } var idElement = new XElement(HbmXml.ElementName("id"), new XAttribute("name", "Id"), new XAttribute("column", "id"), new XAttribute("type", typeof(Int32).Name), new XElement(HbmXml.ElementName("generator"), new XAttribute("class", "native"))); var classElement = new XElement(HbmXml.ElementName("class"), new XAttribute("entity-name", VersionedEntityName), new XAttribute("table", TableName), idElement); var refIdProperty = classElement.CreateProperty(RefIdPropertyName); refIdProperty.Add( new XAttribute("column", ColumnName), new XAttribute("not-null", true), new XAttribute("type", TrackedPersistentClass.IdentifierProperty.Type.Name)); foreach (var property in TrackedPersistentClass.PropertyIterator) { if (Properties.Any(p => p.Name == property.Name)) { AddProperty(classElement, property, mapping); } } var rootElement = new XElement(HbmXml.ElementName("hibernate-mapping"), new XAttribute("auto-import", false), classElement); return(new XDocument(rootElement)); }