【问题标题】:NHibernate BuildSessionFactory() ArgumentException: Keyword not supported: 'initial catalog'NHibernate BuildSessionFactory()ArgumentException:不支持关键字:'初始目录'
【发布时间】:2014-05-27 16:18:38
【问题描述】:

我正在构建一个 ASP.NET MVC 项目并使用 NHibernate 而不是 Entity Framework。

我遇到的问题是在 Configuration 对象中调用 BuildSessionFactory() 方法时出现 ArgumentException: Keyword not supported: 'initial catalog'。

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);

我的连接字符串是

<property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=Passion4Performance;Integrated Security=True</property>

我尝试了很多解决方案,但似乎没有任何解决方法。 提前谢谢你。

【问题讨论】:

    标签: c# asp.net-mvc nhibernate


    【解决方案1】:

    您的配置文件应如下所示:

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      • 1970-01-01
      • 2010-09-21
      • 1970-01-01
      相关资源
      最近更新 更多