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