Click here to Skip to main content
12,244,322 members (50,222 online)
Click here to Skip to main content
Add your own
alternative version

Stats

8.9K views
14 bookmarked
Posted

nHydrate Generator Library

, 18 Feb 2011 Ms-PL
Rate this:
Please Sign up or sign in to vote.
How to use the nHydrate Generator Library.

Introduction

The nHydrate ORM platform is a useful tool for creating data frameworks, inversion of control, and performing other programmatic tasks. However, many generators have been added over the last year and the UI itself has become confusing. At last count, there were 14 different generators. Most people only use one or two, so the rest are just clouding up the generative UI.

To address this issue, a Generator Library has been created. Now when you install nHydrate, there are no generators installed with it. The first time you create or open a model, the library dialog will pop-up allowing you to select a package for download. At present, there is an Entity Framework Data Access Layer (DAL), an ADO.NET DAL, and various other permutations of these and other components. A package contains one or more generators. For example, the ADO.NET DAL package has two assemblies in it. One that generates the DAL and another that generates the database installation/tracking project. These work in tandem to create a matching database and API based on an nHydrate model.

There are more complicated packages of course that include Inversion of Control generators and such, but this simple example demonstrates why packages are downloaded instead of individual generators. Some packages are complex in that there are number dependencies between generated projects so downloading all of them as a unit makes sense.

When you first open a model, you see the Generator Library screen as shown above. The first page shows you the packages available for install. If you already have all the components for a package and they are up to date, the package will not appear in the list. The second page is a list of all installed generators. There can be multiple generators in one package. So after you install a package, there may be many items in your installed list. When updating generators, you will need to close and re-open Visual Studio as the assemblies are locked on disk. You will be prompted to do this if it is necessary. When downloading a new package, this step will not be necessary of course.

Once you download a package, it will be removed from the displayed list. Now you can close the dialog and start generating. I have downloaded the ADO.NET package in this example. After creating my model, I choose the Tools|Generate menu. This will display a generate dialog that prompts me for which projects I wish to create. Notice that there are two generator templates in this dialog now. The package I downloaded had two items in it: the DAL and the database installer. I will use both of these projects as my API and database must be kept in sync.

After I generate, you can see the new projects in my solution. As I change my model and re-generate, these two projects will always be in sync. As I add/remove/rename tables, columns, etc., both my API and database installer will always match. This is the beauty of model driven development.

There are many more generator templates that can be downloaded and you can write your own generators that create code based on a model as well. You can see that this is a simple way to defining a development model and using predefined templates to create code. Another bonus is that all generated projects are based on the same model so when you re-generate, your entire solution/platform is updated and in sync.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Christopher R Davis
Software Developer (Senior) Hewlett Packard
United States United States
I currently work in security at HP and create developer tools. I have been working with technology since the VIC 20. I am currently co-authoring the nHydrate code generator (and other projects) with Michael Knight in Atlanta, GA. We have built a faceted navigation engine that allows you to list any set of objects (cars, jobs, apartments, etc) on a website that gives users the click-through experience. My goal is no more advanced search pages.

I use nHydrate at my day job every day and use it manage a a complex system for HP.

Check out the current nHydrate site on Codeplex. http://nhydrate.codeplex.com



My LinkedIn Profile

LinkedIn nHydrate Group

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 18 Feb 2011
Article Copyright 2011 by Christopher R Davis
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid