0
我建立使用流利的NHibernate和每一個博客文章我讀功能NHibernate一個示例應用程序說,下面的代碼創建一個模式,對我(滴和數據庫叢鬆)更新數據庫。但他們從來沒有提到如何在Visual Studio中執行它。構建Web應用程序時如何觸發Schema Export/Update?
var sessionFactory = FluentNHibernate
.Cfg.Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2008.ConnectionString(
c => c.FromConnectionStringWithKey("ServicesDb")))
.CurrentSessionContext("Web")
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SqlCommandFactory>())
.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)) //Whne this is included
.BuildSessionFactory();
現在,當構建一個web應用程序時,我所能做的就是構建我的代碼。有沒有我可以在Package Manager Console
執行的命令。與實體框架代碼優先和自動遷移一樣,我可以運行Update-Database -Force
,並且我的數據庫將被更新。
我使用' Ninject'和我發佈的代碼在該配置中f ile,以及其他'Bindings'列表。 – Komengem
@Komenge Mwandila:那麼你不得不做任何事情。只要代碼執行,模式將在必要時更新 –
當你什麼也沒說,這是否意味着一旦我建立我的代碼,數據庫應該更新,或者當我運行調試? – Komengem