1
Is it possible through Fluentnhibernate to create the database as tables are created? I have the following class:
public class Helper : IRepositorioHelper
{
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory()
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012
.ConnectionString(x => x
.Server(".\\Servidor")
.Database("BaseDados")
.Username("sa")
.Password("****"))
.ShowSql())
.Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(true, true))
.BuildSessionFactory();
return _sessionFactory;
}
public static ISession OpenSession()
{
return SessionFactory().OpenSession();
}
public void CriaDatabase()
{
SessionFactory();
}
}
With it I can create tables without problems but I wanted to know if it is also possible to create the basis to make it even easier when distributing my application.