I understand the thread is now so old, but I wonder if Nopcommerce have a solution for such case now!?
No, this has not been addressed. There is a link to a work item for this, which is listed as proposed. Make sure to upvote it to help get it into the list of items for an upcoming release.
Here is my Map Class public class DealOfDayProductMap : EntityTypeConfiguration<DealOfDayProduct> { public DealOfDayProductMap() { this.ToTable("DealOfDayProduct");
//Mapping the follower table with vendoer table by vendor Id this.HasRequired(v => v.Vendor) .WithMany() .HasForeignKey(v => v.VendorId);
//Mapping the follower table with Customer table by Customer Id this.HasRequired(c => c.Customer) .WithMany() .HasForeignKey(c => c.CustomerId);
Unable to determine the principal end of an association between the types 'Nop.Core.Domain.Orders.Order' and 'Nop.Core.Domain.Customers.RewardPointsHistory'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
public partial class ActionTargetProductVariantMap : EntityTypeConfiguration<Nop.Plugin.SoftAIN.Action.Domain.ActionTargetProductVariant> { public ActionTargetProductVariantMap() { this.ToTable("Action_TargetProductVariant"); this.HasKey(atp => atp.Id);
Order (collection instead one property): --------------------------------------------- public virtual ICollection<RewardPointsHistory> RedeemedRewardPointsEntities { get; set; }
public RewardPointsHistory RedeemedRewardPointsEntry { get { return RedeemedRewardPointsEntities == null ? null : RedeemedRewardPointsEntities.FirstOrDefault(); } set { } }
And, in the database, in table RewardPointsHistory I replaced UsedWithOrder_Id by UsedWithOrderId to follow the conditions (it prevernts creating a new FK by EF).
I understand, that the fixes above is a workaround, not the solution, so, maybe, there is a better way?
Hello Can you let me know what exactly I need to change in my code to Extend data model with reference table because I am also getting the same Issue.
"In custom context classes we cannot reference previously existing entities because those types are already associated to another object context. That is also why we do not have complex navigation properties in our tracking record."
Hi. It seems to be old problem and yet I have same issue on version 3.90. I have an extension of OrderItem class. While getting list of order items I'm trying to eliminate ones belonging to deleted order:
At this point I get same exception. As you can see I'm not referencing Order instance directly. Instead I'm trying to get one via IOrderService. But still get same problem.