将Fluent 1.2从NH 3.0升级到3.1时发出警告 - ProxyFactoryFactory已过时,已移至

时间:2011-07-27 00:57:26

标签: fluent-nhibernate

我是NHibernate和Fluent NHibernate的新手,我已经使用Fluent 1.2 for NH 3.0大约6个月了。我刚刚升级到Fluent 1.2 for NH 3.1。现在我收到一个警告(在Visual Studio中),我试图解决它,但没有运气。我可以帮忙......

在我的Global.asax文件中,我精通配置NHibernate:

var nhConfig = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connstr =>     connstr.FromConnectionStringWithKey("MyDatabase"))                
.ProxyFactoryFactory<ProxyFactoryFactory>().AdoNetBatchSize(100))
.Mappings(mappings => mappings.FluentMappings.AddFromAssemblyOf<MyClass>())
.ExposeConfiguration(c => c.Properties.Add("current_session_context_class", "web"))
.BuildConfiguration();

我收到警告:

.ProxyFactoryFactory<ProxyFactoryFactory>().AdoNetBatchSize(100))

这是警告:

FluentNHibernate.Cfg.Db.PersistenceConfiguration<FluentNHibernate.Cfg.Db.MsSqlConfiguration,
FluentNHibernate.Cfg.Db.MsSqlConnectionStringBuilder>.ProxyFactoryFactory<TProxyFactoryFactor  y>()'
 is obsolete: 'Moved to FluentConfiguration  Fluently.Configure().ProxyFactoryFactory(...))'

我想我需要使用FluentlyConfigure()。ProxyFactoryFactory(),但该方法的help / intellisense说它只适用于NH 2.1。

我应该在配置中做些什么来消除此警告而不使用过时/弃用的方法?

感谢。

1 个答案:

答案 0 :(得分:4)

在最后几个FluentNHibernate构建中,ProxyFactoryFactory方法已移出Database直接移出Configure。试试这个:

var nhConfig = Fluently.Configure()
.ProxyFactoryFactory<ProxyFactoryFactory>()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("MyDatabase").AdoNetBatchSize(100))
.Mappings(mappings => mappings.FluentMappings.AddFromAssemblyOf<MyClass>())
.ExposeConfiguration(c => c.Properties.Add("current_session_context_class", "web"))
.BuildConfiguration();