Creating a database schema with Fluent NHibernate - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Tuesday, August 7, 2018

Creating a database schema with Fluent NHibernate

If you create your model in C# first, and then want to create a database schema that matches that model, you can do this easily with Fluent NHibernate. First, you need some sort of Data Access Initialization class. public class DataAccessInitializer { private static ISessionFactory sessionFactory; private readonly FluentConfiguration fluentConfiguration; private Configuration nhibernateConfiguration; public DataAccessInitializer() { //Fluently configure nHibernate and save the nHibernate config that has been created by Fluent fluentConfiguration = CreateFluentConfiguration().ExposeConfiguration(cfg = nhibernateConfiguration = cfg); } public Configuration NhibernateConfiguration { get { return nhibernateConfiguration; } } public ISessionFactory CreateSessionFactory() { return sessionFactory ?? (sessionFactory = fluentConfiguration.BuildSessionFactory()); } private static FluentConfiguration CreateFluentConfiguration() { var entitiesToMapConfiguration = new EntitiesToMapConfiguration(); return Fluently.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

.NET,Fluent NHibernate,NHibernate,C#

No comments:

Post a Comment