0
我在ASP.net MVC 3.0項目中使用Fluent Nhibernate和MSSql 2008。「在配置中找不到方言」Fluent Nhibernate
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;
}
但是,我得到這個錯誤「找不到在配置方言」
MsSqlConfiguration.MsSql2008 - 這個初始化方言 – ruskin
是的,這個工作簡單,是很簡單的。您甚至可以將連接字符串更改爲:.ConnectionString(c => c.FromConnectionStringWithKey(「DefaultConnection」))並將其從web.config文件中提取出來。 – Astaar