nhibernate的时候出现的错误
XML validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息。 使用nhibernate的时候出现的错误。
在Default.aspx.cs 里写操作数据库的代码,比如插入:
protected void Button2_Click(object sender, EventArgs e)
{
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddXmlFile(Server.MapPath("Customer.hbm.xml"));
ISession session = cfg.BuildSessionFactory().OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;
session.Save(newUser);
transaction.Commit();
session.Close();
}
以下是数据库为sql server 的nhibernate配置节:
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
value="true"/>
value="NHibernate.Connection.DriverConnectionProvider"/>
value="NHibernate.Dialect.MsSql2000Dialect"/>
value="NHibernate.Driver.SqlClientDriver"/>
value="Data Source=server;Initial Catalog=schema;User ID=username;Password=password"/>
我想知道是什么原因?怎么解决?
----------------------------------------------------------------------
hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
改为
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">