NHiBernate学习笔记(1)
看了abluedog的系列作品——NHibernate Step by Step。发觉终于知道这个大名鼎鼎的NHibernate是什么东西了,今天仅看了第一篇,发现在我的环境下运行无法通过。郁闷……,但是看了后面的回复(140楼的仁兄)后知道了问题的所在。现在把他的回复粘贴出来,方便自己查阅:
1
//按照你的步骤做
2
Configuration config = new Configuration().AddAssembly("Test.Model");
3
//这一句出错
4
//提示: Test.Model.Person.hbm.xml(2,2): XML //validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息。
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
//解决方法:修改Test.Model.Person.hbm.xml中“urn:nhibernate-mapping-2.0”为“urn:nhibernate-mapping-2.2”
7
//修改Test.Model.Person.cs为:
8
public virtual int Id
9
{
10
get {return _id;}
11
set {_id = value;}
12
}
13![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
public virtual string Name
15
{
16
get { return _name; }
17
set
18
{
19
if ( value != null && value.Length > 50)
20
throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
21
_name = value;
22
}
23
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)