Ignore one property of a complex type
c#, ef-code-first, entity-framework, entity-framework-6
Solution
public class AmountsMap : EntityTypeConfiguration<Amounts>
{
public AmountsMap()
{
Ignore(a => a.FinalTotal);
}
}
Problem
I want to ignore one property of a complex type for mapping to the database where FinalTotal is a computed field. Entity Framework says that it isn't allowed and that it must be a property. :( ``` public class Sale { public int Id { get; set; } public DateTime DateSale { get; set; } public Amounts Amounts { get; set; } } public class Amounts { public decimal Subtotal { get; set; } public decimal Tax { get; set; } public decimal FinalTotal { get; set; } } public class SaleMap : EntityTypeConfiguration<Sale> { public SaleMap() { Ignore(s => s.Amounts.FinalTotal); } } ```