This project is read-only.

Script generation

Oct 5, 2012 at 10:33 PM

Love the nHydrate model.

My job requires database modification scripts that are written in a specific format.

How do I hook into the nHydrate model to produce scripts based on a template I provide or based on some code that I use?

Oct 14, 2012 at 12:35 AM

Well the easist thing to do is clone an existing project like EFDAL.Interfaces because it is simple. Then remove all most of the code. Notice there the two base classes BaseProjectGenerator and BaseClassTemplate.  Just follow the pattern they set. That will generate a project into your solution. Then to look at the ViewEntity folder in that project. Notice that there are 4 files. The ExtenderGenerator and EntityExtenderTemplate classes will emit a gen-once class. The GeneratedGenerator and GenerateTemplate will emit a gen-always file as a child of the extender. If you look at the emitted files of a compare EFDAL.Interfaces project you can figure it out. 

For scripts this is probably over kill. You will probably want to just emit a single gen-once file with a version number or something. You can control the file name with the generator class. You write the actual code or script in the template file. The generator controls, calls and emits the template class.