Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate Database-First

I'm putting a front-end together for one of our databases and would like to use NHibernate for it.

Can anyone point out any resources for getting started with Database-first approach? Most tutorials I've seen are for Code/Entity First.

ASP.NET MVC 3 will be my environment, if it matters.

Thanks.

like image 407
Nasir Avatar asked Mar 15 '26 17:03

Nasir


2 Answers

It is all about configuring with NHibernate. As long as Nhibernate is concern, it will not create a database if that is not exists. So you have to configure Nhibernate with the connection string of your existing database in hibernate.cfg.xml(You can also use loquacious api)

There are lots of configuration possibility in NHibernate; Example includes ConfORM, FluentNhibernate, Configuring With Code, XML.

For existing database going with xml is often easy. If you choose xml, you can use tools like myGeneration to generate mappings for you.

As long as you map your object correctly with the existing database nibernate will not complain whether you create your database first or code first. So any intorductory example/application/resource that uses nhibernate as an orm mapper should serve as getting started for you.

Still there are some techniques you can follow to do database first modeling. Here is a link that may help(code example) Effective Techniques for Database-Driven Modeling

Here is the Screen Cast Explaining the techniques

like image 156
Shuhel Ahmed Avatar answered Mar 18 '26 01:03

Shuhel Ahmed


please take a look at this: http://www.devart.com/entitydeveloper/nhibernate-designer.html it is not a freeware.

There is another open source tool which was referred in another question long time back. here is the link: http://www.mygenerationsoftware.com/phpBB2/viewtopic.php?t=1505

btw are you planning to use fluent nhibenrate or just nhibernate?

On a side note: Entity Framework supports a database-first approach with an integrated designer for Visual Studio. This designer produces an XML file (EDMX) that describes the required mappings.

Note: I am not marketing any of these products.

like image 34
Baz1nga Avatar answered Mar 18 '26 02:03

Baz1nga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!