ASP.NET MVC, DynamicData, Domain-/RiaServices, Unity and NHibernate: Part 1

by . 0 Comments

I’ve been playing with RIAServices and DynamicData lately, and managed to combine these with NHibernate as ORM in an ASP.NET MVC project.

For this project the following (extensive) list of libraries is used (all these libraries are included in the download):

Besides using these libraries, I copied some code snippits from the Kigg project, which has quite a nice codebase!

In the first part of this serie, I’ll show you how you can use these libraries along with my own code to scaffold the entire Northwind database in an mvc project. It’ll be totally hassle-free, I promise! It will generate classes from the database-schema and I will also show you how to override the default generated domainservices and repositories (yes, those are generated at runtime if you don’t specify your own!).

In the upcoming parts, I will add client-side validation and some ajax-love to the scaffold pages. In one of those parts I’ll also explain how my code works, and what it does. I’m also thinking about showing how to replace some parts of the library, since it’s very pluggable. I could for example replace the persistencelayer with Linq-to-Sql or replace the Depency part with StructureMap.

Although this sample shows you how to use an existing database, it would ofcourse be best if you could use the Model-first approach! Luckely nHibernate makes this very simple as well. If you create the entity files in your project and have them inherited from BaseEntity, all you have to do is add this line to your Application_Start:

new SchemaUpdate(IoC.Resolve<Configuration>).Execute(true, true);

Your database schema will be automatically updated if you change anything to your Model.

You can watch the screencast here and download the sample + dll’s here


For the next screencast, I’ll by a mic so I don’t have to subtitle it ;-)

0 Responses to ASP.NET MVC, DynamicData, Domain-/RiaServices, Unity and NHibernate: Part 1

  1. 9eFish says:

    » ASP.NET MVC, DynamicData, Domain-/RiaServices, Unity and NHibernate: Part 1…

    9efish.感谢你的文章 – Trackback from 9eFish…

  2. Parag Mehta says:

    Excellent! Just a question : what software you used to create the screencast ? I am not native english speaker, so interested in how you subtitled the screencast :).

    Great screencast, waiting for more iterations…

  3. Exploring MVC architecture | Softwarefun says:

    […] I realy like this one: ASP.NET MVC, DynamicData, Domain-/RiaServices, Unity and NHibernate: Part 1 […]

  4. Jimit Ndiaye says:

    Wow! This is some of the coolest stuff I’ve seen in a while! Keep it coming! Now if only the REST model for RIA domain services could be consumed remotely, I’d be saying goodbye Astoria. :)

  5. Atam says:

    Hi Chris, nice work. I’m also from the Netherlands (Hoofddorp).

    Something is bothering me. Its is nice to see a well thought framework using NHibernate and Riaservices, business rules ect. The problem for me is, that i build an alike framework (also using NHibernate as possible DAL) and RiaServices, but i want to use Silverlight.

    The problem then becomes that Silverlight generates client side proxies. If your domain object properties have code for validation ect you will lose that. Also Silverlight can only refer to Silverlight projects/assemblies.

    So i was wondering if you have tried using above code with Silverlight instead of MVC.

    Thanks in advance.

  6. Sean says:

    Thanks Christ! great presentation. and now the new version of MVC and RiaServices are out. would you be interested to update your demo to take advantage of the vs2010?


  7. Daniel says:

    Wow man… That is really nice!!!

    I would like to know if there is a way to use Silverlight as the View, using the services published by Ria Services?

    But, really, really cool!!!

  8. Chris van de Steeg says:

    @all: sorry for the lack in updates and response.
    Will try and pick up where I left soon

  9. Sanjay says:

    Thanks for the post Chris. I am also interested in using NHibernate + RIA with Silverlight. Could you please throw some light on it?

  10. Felicita Chhon says:

    Hey, I really don’t think saying this on your post ASP.NET MVC, DynamicData, Domain-/RiaServices, Unity and NHibernate: Part 1 | Chris van de Steeg would be the correct place however I wasn’t able to locate a contact page within your somewhat messy theme (sorry). My visitors would always tell me the exact same thing so I converted to a new theme from I have only gotten kind comments since. Cheers, Felicita Chhon

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>