Page 1 of 1

NHibernate File Names

Posted: Thu 18 Apr 2013 15:40
by smlemmon
Hi,

I just wondered if there is any way to stop the file names that are generate for the NHibernate entities and mapping files being prefixed with the model name.

For example, if my model name is TestModel, all the generated files come out as :-

TestModel.Xxxxxxx.cs etc...

I just want the name to be Xxxxxx.cs without the model name prefix.

Many thanks

Simon

Re: NHibernate File Names

Posted: Mon 22 Apr 2013 08:31
by Shalex
For this, you should modify a code generation template manually:
1) right click on the template in Model Explorer > Copy to Model Folder
2) open template and replace

Code: Select all

string rootFileName = baseFileName + "." + cls.Name;
with

Code: Select all

string rootFileName = cls.Name;
3) save template and regenerate the code.

Re: NHibernate File Names

Posted: Thu 09 May 2013 21:23
by Joe Smith
The naming stategy of ED is indeed odd, IMHO.
I hope this will change in a future release because I'd rather not change the standard template manually.

Re: NHibernate File Names

Posted: Wed 15 May 2013 06:38
by Shalex
Generating names like TestModel.Xxxxxxx.cs is a common feature of different ORM designers. Different models within a project may have classes with the same name; as a result one file overwrites another one when naming Xxxxxxx.cs is used.