Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Can a mapping document be generated in nhibernate?


Asked by Dominik Herman on Dec 08, 2021 FAQ



Note that, even though many NHibernate users choose to define XML mappings by hand, a number of tools exist to generate the mapping document, even transparently at runtime.
Also,
NHibernate require mapping streams to bind your domain model to your database. Usually, they are written (and maintained) in separated hbm.xml files. With NHibernate.Mapping.Attributes, you can use .NET attributes to decorate your entities and these attributes will be used to generate these mapping .hbm.xml (as files or streams).
One may also ask, Mapping entities is straightforward, entity classes are always mapped to database tables using <class>, <subclass>, and <joined-subclass> mapping elements. Value types need something more, which is where mapping types are required. NHibernate is able to map a wide variety of data types.
Subsequently,
As you can see that enumeration has a variety of different values that it can possibly have such as, Excellent, Good, Fair, Poor and Terrible. Jumping over to the mapping file, you can see that each of these properties are listed out in the mapping file including the newly added AcademicStanding property.
Thereof,
This is a convention used by NHibernate to automatically recognize the file as a mapping file. Define "Embedded Resource" as Build Action for this xml file. In the Windows Explorer locate the nhibernate-mapping.xsd in the src folder of NHibernate and copy it to your SharedLibs folder.