我如何通过 nhibernate fluent 在 sql server 中创建数据库。我使用这个代码:
string server = "localhost\\SQLEXPRESS";
string database = "NameDb";
const string user = "admin";
const string password = "admin";
var connectionString = string.Format("Server={0};Database={1};User Id={2};Password={3};",
server, database, user, password);
var autoMap = AutoMap.AssemblyOf<AggregateBase>()
.Where(t => typeof(AggregateBase).IsAssignableFrom(t));
SessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString))
.Mappings(m => m.AutoMappings.Add(autoMap))
.ExposeConfiguration(TreatConfiguration)
.BuildSessionFactory();
protected static void TreatConfiguration(NHibernate.Cfg.Configuration configuration)
{
var update = new SchemaUpdate(configuration);
update.Execute(false, true);
}
但它只创建模式,如果 sql server 中没有 namedb 则没有生成数据库