How to add NHibernate XML schema to Visual Studio?

落爺英雄遲暮 提交于 2019-12-05 10:46:32

问题


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

Could not find schema information for the element '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?


回答1:


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




回答2:


Copy the two .xsd from the folder Required_Bins from 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.




回答3:


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

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

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

  3. Click Add

  4. Browse to your Solution and open the packages folder in the root

  5. Find the nHibernate package folder

  6. Select both the XSD files within the lib folder




回答4:


I tried some of the above ideas with VS2012 and NHibernate 3.3.1.4000 and it did not work, but the following tip given by ArnonA worked for me. It should also be SVN safe, if you work on multiple projects with different versions of 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 :)



回答5:


Just copy the nhibernate.xxx.xsd files into your

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

folder.




回答6:


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.



来源:https://stackoverflow.com/questions/3565156/how-to-add-nhibernate-xml-schema-to-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!