When creating a model in Entity Developer for NHibernate, you can import existing NHibernate xml-mappings from various sources:
• | NHibernate XML mapping file (*.hbm.xml). In this case the mapping being imported is taken from a XML mapping file (.hbm.xml). |
• | C# or Visual Basic Visual Studio project file (*.csproj, *.vbproj). In this case all .hbm.xml files being sub-items of the project are imported. |
• | Assembly or executable file compiled for .NET Framework (*.dll, *.exe). In this case the mapping for import is taken from the file resources, i.e. XML mapping files (.hbm.xml) are looked for in the resources. |
NHibernate allows not to specify entity properties type explicitly in xml-mapping and runtime defines it itself during the execution. In this case, XML mapping files alone are not enough for successful import and for defining property types additional files are required. With their help missing information about types can be obtained. They can be C# or Visual Basic files containing code that defines classes of entities being imported, and after parsing the code of these classes, we can get the information about the types of their properties. They can also be C# or Visual Basic Visual Studio projects, then, going from one item of the project to another, classes for entities being imported will be found, and after parsing the code of these classes, the information about the types of their properties will be available. Also, assemblies and executable EXE files compiled for .Net Framework can be the source of missing information about types, then information about classes for entities being imported and types of their properties can be found with the help of reflection. In case missing data cannot be found, the property is excluded from the entity being imported. It should be taken into consideration, that additional files as the source of information about property types of entities being imported, are required only in case information about types is absent in the XML mapping file, and if this file contains all the necessary data, then no additional files are required.
|
Remember that additional files containing information about classes for entities being imported are used only as the source of data for property types that are missing from the XML mapping file and classes defined in them are not imported into the model as its entities. Only the xml-mapping being imported is the source of the entities being imported.
|
To import an external NHibernate mapping, perform the following steps:
1. | In Entity Developer, select the File menu, and then select the New model menu item. |
2. | In the New Model dialog, select Devart NHibernate model and click the Create button. |
3. | On the first page of Create Model Wizard, select the Import option and click Next. |
4. | On the Import Mappings page of Create Model Wizard, either click Add files to add one or more files, or click Add Folder to add a folder containing required files, or click Remove to remove unwanted files. |
6. | The Import results page of Create Model Wizard displays the outcome of the import process: the list of imported entities and information about errors, if any. |
7. | On the next page of Create Model Wizard, select the required code generation template and click Next. |
8. | On final page of the wizard, click Finish. |
Send feedback on this topic
© 2008 - 2024 Devart. All rights reserved.