【发布时间】:2014-10-04 12:13:22
【问题描述】:
我正在考虑在 mycommerce 引擎中添加一个新表;
关系
[Product] 1..* [Awards]
代码文件:
public partial class Awards : BaseEntity, ILocalizedEntity
{
public virtual Product Product { get; set; }
public string AwardDescription { get; set; }
public Guid AwardGUID { get; set; }
public int Product_Id { get; set; }
}
public partial class AwardsMap : EntityTypeConfiguration<Awards>
{
public AwardsMap()
{
this.ToTable("Awards");
this.HasKey(p => p.Id);
this.Property(p => p.AwardGUID).IsOptional();
this.Property(p => p.AwardDescription).IsOptional();
this.HasRequired(p => p.Product)
.WithMany(pt => pt.ProductAwards)
.Map(m => m.ToTable("Awards"));
}
}
public partial interface IAwardsService
{
void DeleteAwards(Awards Awards);
IList<Awards> GetAllAwardss();
Awards GetAwardsById(int AwardsId);
void InsertAwards(Awards Awards);
void UpdateAwards(Awards Awards);
}
还有实现IAwardsService接口的AwardsService.cs类(与ProductTagService.cs一样)
Product.cs代码sn-p:
private ICollection<Awards> _awards;
public virtual ICollection<Awards> ProductAwards
{
get { return _awards ?? (_awards = new List<Awards>()); }
protected set { _awards = value; }
}
但每次我从数据库加载产品并尝试加载 ProductAwards 属性时,我都会收到错误
Invalid column name 'Product_Id1'.
Invalid column name 'Product_Id1'.
发生了什么事?
编辑
我看到了Customer, CustomerAddress, Address 表,我已经修改了我的类,使其看起来与那些相同,现在它可以工作了。
【问题讨论】:
标签: c# asp.net-mvc nopcommerce