Skip to main content
 首页 » 编程设计

c#之nhibernate nuget之找不到架构

2024年02月13日18jpfss

我启动了一个 asp.net mvc 项目,我正在尝试使用 nibernate 进行数据库访问。

我在 visual studio 中收到以下警告:

Could not find schema information for the element 'urn:nhibernate-configuration-2.2:hibernate-configuration'.    
Could not find schema information for the element 'urn:nhibernate-configuration-2.2:session-factory'. 
Could not find schema information for the element 'urn:nhibernate-configuration-2.2:property'.   
Could not find schema information for the attribute 'name'.  
Could not find schema information for the element 'urn:nhibernate-configuration-2.2:property'.   
Could not find schema information for the attribute 'name'.  
Could not find schema information for the element 'urn:nhibernate-configuration-2.2:property'.   
Could not find schema information for the attribute 'name'.  

我的 Web.conf:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
  <configSections> 
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> 
  </configSections> 
.... 
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
    <session-factory> 
      <property name="dialect">NHibernate.Dialect.MySQLDialect</property> 
      <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> 
      <property name="connection.connection_string_name">MainDb</property> 
    </session-factory> 
  </hibernate-configuration> 
... 

我通过 nuget 安装了 nhibernate。

有什么想法吗? 提前致谢。

请您参考如下方法:

通常你可以忽略它。

但如果需要,您可以将架构添加到 Visual Studio 中的 XML 验证中。 XML 菜单 > 架构 > 添加

从您的包文件夹中选择 nhibernate-configuration.xsd

packages\NHibernate\lib\<.NetVersion>

现在 VS 应该能够正确验证您的 xml (web.config)。