开发者

Ways to generate database full structure based on Fluent NHibernate mappings

开发者 https://www.devze.com 2022-12-25 20:22 出处:网络
I\'m looking for ways to generate the application database full structure based on the NHibernate mapping data. The idea is to give the user an option to supply a database-connection string and then t

I'm looking for ways to generate the application database full structure based on the NHibernate mapping data. The idea is to give the user an option to supply a database-connection string and then to build their a database with the structure that the application needs.

The database nee开发者_如何学Cd to independent - it means that it needs to work with any database that are supported by NHibernate.

By full structure I mean that I want to generate also the index fields, and the relationship between tables.

Is their few ways to accomplish this with NHibernate? Is so, what are they?


You use the SchemaExport class for this purpose. The API is a little odd but it works nonetheless.


You can generate a full database from your C# classes using FNH automapping - I've been doing it on my project for several months now, and I love it!

It's powerful enough to automatically map a deeply nested object graph, including Lists of objects.

It creates all the relationships for you, but - for SQLite, at least - not the indexes.

See http://wiki.fluentnhibernate.org/Auto_mapping for more info.

See http://fnhsamples.codeplex.com/ for a fully working example, kindly provided by Nikola Malovic.

0

精彩评论

暂无评论...
验证码 换一张
取 消