This project is read-only.

Change output directory during code generation

Oct 19, 2010 at 11:18 AM

Hi all,

Is it possible to change the pathway that NHydrate uses when generating the class libraries? I don't want the code to be generated to the directory that contains the *.sln, but to a directory within that directory. Many thanks,


Oct 19, 2010 at 2:06 PM

The files are tied to where the project files are located not the solution.

You are correct that the generator puts the files in a location based on the *.sln.

However, this is only the first time "When the project file is created". If you move the files after creation. The generator will put those files where the project file is located.



Oct 20, 2010 at 1:27 PM

He is saying for now, you can generate and then remove the project from your solution. You may then move the project/folder to where ever you wish and add the project back to your solution. From then on all files for that project are generated into that project so it does not matter where the project is. In summary, generate the projects, remove from solution, arrange on disk however you wish and add the projects back to the solution.

Nov 15, 2010 at 12:03 PM

Thanks for your replies. It does seem to work this way for me, here's what's happening:

  • Create a model and generate the code for the first time - projects are put in the same directory as my solution file
  • I move the libraries to a sub-folder within the directory
  • If I regenerate new code after altering the model, a set of new libraries are generated in the same directory as the solution file again - not the 'new' location

Am I doing something wrong? It's pretty annoying cos I have to delete the old libraries from svn, then move and add the new libraries every time I regenerate code. 

Nov 16, 2010 at 3:35 AM

Please confirm that you are not moving the libraries meaning assemblies but you are doing this.

  1. Remove the generated projects from your solution.
  2. Go to disk and move the generated folders to the location desired.
  3. Now re-add these projects to your solution.
Nov 16, 2010 at 9:34 AM

Yep, that's what I'm doing - I'm removing the projects from the solution, moving the folder containing the NHydrate projects(s) to a new location, then adding the project(s) back to the solution.

Nov 29, 2010 at 3:26 PM

OK, this definitely isn't work like you say it should. Should I report it as a bug? I've done it at least five times now, each time I have to spend ages reordering my project and messing with svn.

Nov 29, 2010 at 11:57 PM

We might be talking about different things because we have verified on this that this works as stated. We have tested this on various machines. These are the steps we take. I do not know what else we can do. We have actually used the functionality you describe for years because, just like you, we do need to rearrange our projects sometimes. Here is how we tested.

Create an empty solution
Add a new model to the solution
Add some tables to the model and generate
The generated projects are in new folders created at the same level as the SLN file
We then remove the projects from our solution
We then create a subfolder called "NewFolder" in the folder that contains the solution file
We then move the generated folders to this new folder
At this point the base folder has our solution SLN file and 1 folder named "NewFolder"
In VS.NET our solution has no projects in it now of course so we add the projects located in our base folder/"NewFolder"
We then mess up some of the generated files by adding random text into it
We then re-generate the model again and see the generated files overwritten
Looking in our solution folder we do not see any new folders created there is still just "NewFolder"
We have verified that our model is being generated and we have verified that the folder structure we have manually created on disk still exists


Nov 30, 2010 at 3:40 PM

Must be something funny going on with my machine.

Thanks for looking into it, and great tool by the way. 

Cheers, Matt.