visual-studio 如何将 NHibernate XML 架构添加到 Visual Studio?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3565156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:22:43  来源:igfitidea点击:

How to add NHibernate XML schema to Visual Studio?

visual-studionhibernateintellisense

提问by svick

I'm learning NHibernate and I added <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">to App.config. Visual Studio reported a message:

我正在学习 NHibernate 并添加<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">App.config. Visual Studio 报告了一条消息:

Could not find schema information for the element 'urn:nhibernate-configuration-2.2:hibernate-configuration'.

找不到元素“urn:nhibernate-configuration-2.2:hibernate-configuration”的架构信息。

I know this is not a problem, but if VS knew the schema, IntelliSense would work. How can I add the schema?

我知道这不是问题,但如果 VS 知道架构,IntelliSense 就会起作用。如何添加架构?

采纳答案by svick

Copy the two .xsdfrom the folder Required_Binsfrom the NHibernate download to C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas. If you use other version of VS than 2008 (or if you have VS installed elsewhere), change the path accordingly.

将NHibernate 下载.xsd文件夹中的两个复制Required_Bins到 C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas。如果您使用 VS 的其他版本而不是 2008(或者如果您在其他地方安装了 VS),请相应地更改路径。

回答by Diego Mijelshon

Just include the XSD files in any of your projects or as Solution Items.

只需将 XSD 文件包含在您的任何项目中或作为解决方案项。

回答by neilhighley

For those using nuget, and multiple versions of nHibernate, Source control, et al...

对于那些使用 nuget 和多个版本的 nHibernate、源代码控制等...

  1. Open up the hbm XML file in your project.

  2. Select the XML menu item and select Schemasin the drop down (or press ALT, X, S)

  3. Click Add

  4. Browse to your Solution and open the packagesfolder in the root

  5. Find the nHibernate package folder

  6. Select both the XSD files within the libfolder

  1. 打开项目中的 hbm XML 文件。

  2. 选择 XML 菜单项并Schemas在下拉列表中选择(或按ALTXS

  3. 点击 Add

  4. 浏览到您的解决方案并打开packages根目录中的文件夹

  5. 找到 nHibernate 包文件夹

  6. 选择文件lib夹中的两个 XSD 文件

回答by Patrick D'Souza

I tried some of the above ideas with VS2012 and NHibernate 3.3.1.4000 and it did not work, but the following tipgiven by ArnonAworked for me. It should also be SVN safe, if you work on multiple projects with different versions of nHibernate

我在 VS2012 和 NHibernate 3.3.1.4000 上尝试了上述一些想法,但没有奏效,但ArnonA给出的以下提示对我有用。它也应该是 SVN 安全的,如果您使用不同版本的 nHibernate 处理多个项目

  1. Inside VS2012, open up the nHibernate xml file you would like to edit.
  2. Once in the xml file editor, the XML menu should be visible in the main VS menu.
  3. Click on XML->Schemas menu, this should open the "XML Schemas" dialog.
  4. Add the "nhibernate-configuration.xsd" and "nhibernate-mapping.xsd" files and click ok.
  5. Done :)
  1. 在 VS2012 中,打开您要编辑的 nHibernate xml 文件。
  2. 一旦进入 xml 文件编辑器,XML 菜单应该在主 VS 菜单中可见。
  3. 单击 XML->Schemas 菜单,这将打开“XML Schemas”对话框。
  4. 添加“nhibernate-configuration.xsd”和“nhibernate-mapping.xsd”文件,然后单击确定。
  5. 完毕 :)

回答by Goblin

Just copy the nhibernate.xxx.xsdfiles into your

只需将nhibernate.xxx.xsd文件复制到您的

%Program Files%\Microsoft Visual Studio %version%\xml\Schemas 

folder.

文件夹。

回答by m3l20

You should add xsd files to the solution. This would prevent issues of missing files if your team needs to download the project from a code repository.

您应该将 xsd 文件添加到解决方案中。如果您的团队需要从代码存储库下载项目,这将防止丢失文件的问题。