“在配置中找不到方言”流畅的休眠
我在 ASP.net MVC 3.0 项目中使用 Fluent Nhibernate 和 MSSql 2008。
private static ISessionFactory CreateSessionFactory()
{
FluentConfiguration configuration = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString("Data Source=Comp;Initial Catalog=MyDB;Integrated Security=true")
.ShowSql()).ExposeConfiguration(c => c.SetProperties(AddProperty()))
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf());
return configuration.BuildSessionFactory();
}
private static IDictionary AddProperty()
{
IDictionary config = new Dictionary();
config.Add("current_session_context_class", "web");
config.Add(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
return config;
}
但是,我收到此错误“在配置中找不到方言”
I am using Fluent Nhibernate with MSSql 2008 in an ASP.net MVC 3.0 project.
private static ISessionFactory CreateSessionFactory()
{
FluentConfiguration configuration = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString("Data Source=Comp;Initial Catalog=MyDB;Integrated Security=true")
.ShowSql()).ExposeConfiguration(c => c.SetProperties(AddProperty()))
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf());
return configuration.BuildSessionFactory();
}
private static IDictionary AddProperty()
{
IDictionary config = new Dictionary();
config.Add("current_session_context_class", "web");
config.Add(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
return config;
}
But, I am getting this error "Could not find the dialect in the configuration"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您实际上正在覆盖所有先前配置步骤设置的所有属性。尝试添加到集合中:
You are actually overwriting all the properties that have been set by all previous configuration steps. Try adding to the collection instead:
您可以尝试这样的事情
另外对于 WebSessionContext,您可以使用此代码
You could try something like this
Also for the WebSessionContext, you could use this code