NHibernate create database?

0

I am a Java developer and I work with Hibernate. Now I need to create a desktop application and I decided to use C # for this. I've been researching ORM frameworks for C # and found the Entity Framework and NHibernate. As my experience is greater with Hibernate I decided to adopt NHibernate but I am researching if it is possible for the framework to create the database and tables as it is possible in Hibernate but I have yet to find anything other than creating tables.

I would like to know if NHibernate can create the database?

    
asked by anonymous 26.02.2016 / 19:14

1 answer

1

Good afternoon @FernandoPaiva I do this way with Nhibernate it creates the tables in the bank I will leave link of github with project that I used it.

 public class HibernateUtil
    {
        private static ISessionFactory factory;

        public static ISessionFactory Factory
        {
            get
            {
                if (factory == null)
                {

                    factory = Fluently.Configure()
                        .Database(MsSqlConfiguration.MsSql2008
                        .ConnectionString(ConfigurationManager.ConnectionStrings["webapi"].ConnectionString))
                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<FuncionarioMap>()).
                         ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))
                        .BuildSessionFactory();


                }


                return factory;
            }


        }
    }

link

    
29.02.2016 / 16:47