0
我怎樣才能創建數據庫在sql server通過nhibernate流利。我用這個代碼:創建數據庫nhibernate流利的asp.net mvc
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沒有生成數據庫