Entity framework column mapping for complex types

Viewed 3924

I have complex type class ..Here is hierarchy

 public class Item 
 {
    public virtual Summary Summary { get; set; }
 }

 public class Summary
 {
    public int Id { get; set; }

    [Key, ForeignKey("Item")]
    public int ItemId { get; set; }

    public virtual Item Item { get; set; }

    public virtual ClaimSummary Cost { get; set; }
 }

    [ComplexType]
    public class ClaimSummary
    {
        public virtual decimal? SparePartsCost { get; set; }

        public virtual decimal? LaborHours { get; set; }
                  .....
    }

When I save Item into DB, SQL profiler shows it expects column names as Cost_SparePartsCost where my DB has column name as SparePartsCost. I purposefully created DB column names such a way since I dont want '_' in between names.

How can I let Entity Framework know that columns are mapped such a way that it will ignore its default mapping and follow the custom mapping ?

1 Answers
Related