异常:
The following types may not be used as proxies:
NHibernateDemo.DataAccess.DomainObjects.Customer: method get_Name should be virtual
NHibernateDemo.DataAccess.DomainObjects.PurchaseItem: method set_Id should be virtual.....
需要改的有两点:
例如:Customer.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns=" urn:nhibernate-mapping-2.2">
<class name="NHibernateDemo.DataAccess.DomainObjects.Customer, NHibernateDemo.DataAccess" table="Customer" lazy="false">
<id name="Id" type="Int32" unsaved-value="null">
<column name="ID" length="4" sql-type="int" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="30" sql-type="nvarchar" not-null="true"/>
</property>
<bag name="CustomerPurchases" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="CustomerID"/>
<one-to-many class="NHibernateDemo.DataAccess.DomainObjects.Purchase, NHibernateDemo.DataAccess"/>
</bag>
</class>
</hibernate-mapping>
1.未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息
把 原来的urn:nhibernate-mapping-2.0改为urn:nhibernate-mapping-2.2
2 .在class中添加lazy=false.
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · 动软Nhibernate代码生成模板
- · The instance of entity type ‘Customer’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked.
- · .NET8实时更新nginx ip地址归属地
- · 解决.NET Blazor子组件不刷新问题
- · .NET8如何在普通类库中引用 Microsoft.AspNetCore
- · .NET8 Mysql SSL error
- · ASP.NET Core MVC的Razor视图渲染中文乱码的问题
- · .NETCORE 依赖注入服务生命周期
- · asp.net zero改mysql
- · .NET5面试汇总
- · .Net连接Mysql数据库的Convert Zero Datetime日期问题
- · vue使用element-ui中的Message 、MessageBox 、Notification