【发布时间】:2026-01-04 16:05:02
【问题描述】:
我正在使用 nop Commerce 2.30。我在 nopCommerce 数据库中创建一个表并设置
另一个表中的 1:1 关系。
我的桌子是议程。请看我的表结构。
请看数据库图。
BaseEntity 类
/// <summary>
/// Base class for entities
/// </summary>
public abstract partial class BaseEntity
{
/// <summary>
/// Gets or sets the entity identifier
/// </summary>
public virtual int Id { get; set; }
请查看我的模型。我在我的议程类中添加了一个新的属性 ID。但它是
显示警告消息此属性已经存在它的基类。
命名空间 Nop.Core.Domain.Agendas
{
public partial class Agenda : BaseEntity
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual List<Days> Days { get; set; }
}
}
映射
`公共部分类 AgendaMap : EntityTypeConfiguration
{
public AgendaMap()
{
this.ToTable("Agenda");
this.HasKey(a => a.Id);
}
}`
然后我尝试在议程表中插入。
我收到此错误消息
请帮忙。
【问题讨论】:
-
您是否通过调试检查了 ConferenceId 不为空?
-
不,它不为空。我给的conferenceId是52。但是请看议程的模型类。 Id 属性未定义。 Id 属性是从 BaseEntity 类中获取的。不在议程模型中。我尝试在议程 ID 中插入相同的产品表 ID。
标签: asp.net-mvc asp.net-mvc-3 linq entity-framework nopcommerce