List<Order> orders = orderRepository.Query().Where(x => x.del != true).ToList();
返回错误:
System.Reflection.AmbiguousMatchException- Ambiguous match found.
更重要的是 - 如果没有下面的代码,一切正常。
如何解决?为什么我会收到这个错误?
Order.cs:
public partial class Order
{
(..)
public virtual Country UserCountry { get; set; }
public virtual Country CompanyCountry { get; set; }
public virtual DeliveryType UserDeliveryType { get; set; }
public virtual PaymentType UserPaymentType { get; set; }
//without that virtual properties everything works fine
}
MyContext.cs:
modelBuilder.Entity<Order>()
.HasRequired(u => u.UserCountry)
.WithMany()
.HasForeignKey(u => u.CountryID).WillCascadeOnDelete(false);
modelBuilder.Entity<Order>()
.HasRequired(u => u.CompanyCountry)
.WithMany()
.HasForeignKey(u => u.companyCountry).WillCascadeOnDelete(false);
modelBuilder.Entity<Order>()
.HasRequired(u => u.UserDeliveryType)
.WithMany()
.HasForeignKey(u => u.DeliveryTypeID).WillCascadeOnDelete(false);
modelBuilder.Entity<Order>()
.HasRequired(u => u.UserPaymentType)
.WithMany()
.HasForeignKey(u => u.PaymentTypeID).WillCascadeOnDelete(false);
//and without that part of code