C# NHibernate BuildSessionFactory()参数异常:不支持关键字:';初始目录';
我正在构建一个ASP.NETMVC项目,并使用NHibernate代替实体框架 我遇到的问题是,在配置对象中调用BuildSessionFactory()方法时,我得到一个ArgumentException:关键字not supported:“initial catalog”C# NHibernate BuildSessionFactory()参数异常:不支持关键字:';初始目录';,c#,asp.net-mvc,nhibernate,C#,Asp.net Mvc,Nhibernate,我正在构建一个ASP.NETMVC项目,并使用NHibernate代替实体框架 我遇到的问题是,在配置对象中调用BuildSessionFactory()方法时,我得到一个ArgumentException:关键字not supported:“initial catalog” config = new Configuration(); config.Configure(); sessionFactory = config.BuildSessionFactory(); session = sess
config = new Configuration();
config.Configure();
sessionFactory = config.BuildSessionFactory();
session = sessionFactory.OpenSession();
IList<Catalogue> catalogues = (from c in session.Query<Catalogue>()
select c).ToList();
return this.Json(catalogues, JsonRequestBehavior.AllowGet);
config=新配置();
config.Configure();
sessionFactory=config.BuildSessionFactory();
session=sessionFactory.OpenSession();
IList目录=(来自session.Query()中的c)
选择c.ToList();
返回this.Json(cataloges,JsonRequestBehavior.AllowGet);
我的连接字符串是
<property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=Passion4Performance;Integrated Security=True</property>
数据源=。\SQLEXPRESS;初始目录=性能;集成安全性=真
我尝试了许多解决方案,但似乎没有任何办法解决这个问题。
提前谢谢。您的配置文件应该如下所示:
<connectionStrings>
<add name="NameOfConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Passion4Performance;Integrated Security=True" />
</connectionStrings>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string_name">NameOfConnectionString</property>
</session-factory>
</hibernate-configuration>
连接字符串的名称