Page 1 of 1
Fluent NHibernate
Posted: Sat 21 Nov 2015 16:31
by GlenAvery
Hi,
We are evaluating various tools for generating Fluent NHibernate code from an existing database. I have downloaded the trial version and tried creating a project.
However when I create the DevArt bHibernate model it always creates a hbml xml mapping file even though I select the Fluent NHibernate template.
What am I missing?
Thanks
Glen
Re: Fluent NHibernate
Posted: Mon 23 Nov 2015 07:41
by MariiaI
In case Fluent mapping is used, XML mapping generation should be disabled in the basic NHibernate template. For this, in the Model Explorer (the Model Explorer can be opened by selecting Model Explorer from the Entity Developer submenu of the Tools menu) select Properties from the context menu of the NHibernate template and set the XML Mapping Action property value to 'Do Not Generate Mapping Files'.
Please refer to the corresponding topics in the Entity Developer documentation:
http://www.devart.com/entitydeveloper/e ... eloper.chm > ORM Support -> NHibernate -> Generation -> Entities and Mapping Generation
http://www.devart.com/entitydeveloper/e ... eloper.chm > ORM Support -> NHibernate -> Generation -> Model Generation Templates -> Fluent NHibernate Template
Please tell us if this helps.
Re: Fluent NHibernate
Posted: Mon 23 Nov 2015 08:21
by GlenAvery
Thanks for the reply.
I have tried regenerating the mapping from the database with
XML Mapping Action = Do Not Generate Mapping Files
However still the hbml file was generating including the xml mappings.
I tried it again and added the Fluent NHibernate template and still there is no change in how the mapping was generated.
I have followed the help text and according to these what I did above should be enough.
It seems that no matter which template and setting I use it always generates the same hbml file and does not generate any fluent nhiberate.
Re: Fluent NHibernate
Posted: Mon 23 Nov 2015 11:21
by MariiaI
Did you save the changes after making these steps with the template?
For example, after making the necessary changes to your template properties click "Save All" (Ctrl+Shift+S) or right-click Your_Model.hbml file and select "Run Custom Tool".
Also, make sure that both templates, NHibernate and Fluent NHibernate, are enabled (Enabled is set to True in the Properties window for both templates).
JIC: We are sending you a small test project to the e-mail address you provided in your forum profile. Please check that it is not blocked by your mail filter.
Re: Fluent NHibernate
Posted: Mon 23 Nov 2015 13:47
by GlenAvery
In the Fluent NHibernate, when I changed File Per Class to False then it generated the mappings. Otherwise it generates empty mapping classes?
In any case it looks better now.
Thanks!
Re: Fluent NHibernate
Posted: Tue 24 Nov 2015 07:22
by MariiaI
GlenAvery wrote:In the Fluent NHibernate, when I changed File Per Class to False then it generated the mappings. Otherwise it generates empty mapping classes?
Most likely, you set the "Generate Partial Class" option to True in the Properties of the used template and the files of the partial classes were generated (these files are generated only once when the model is created; they are not regenerated after any changes to the model to save your manual changes).
To see the fluent mapping, open the YourModel.YourClass.FluentMapping.Generated.cs file.
Please notify us about the results.