if the entity as
public class AddressDetail
{
public string Country{get;set;}
}
public class Order
{
public AddressDetail AddressDetail{get;set;}
}
How ignore the Oreder.AddressDetail.Country
property by Fluent API Not [NotMap]
?
I found the solution for EF6 ,but I don't know Why Before EF6 have the function,EF6 don't have the function?
For EF5 and older: In the
DbContext.OnModelCreating
override for your context:
modelBuilder.Entity<Product>().Ignore(p => p.AddressDetails.Country);
For EF6: You're out of luck. See Mrchief's answer .
I understand this exception that only plain property expressions are allowed, so if you want to ignore the property of a property, you have to do it on the type of the outer property:
modelBuilder.Types<WhateverTheTypeOfResponseIs>()
.Configure(c => c.Ignore(r => r.MobilePhone));
Though, i guess the proper syntax for EF6 would be:
modelBuilder.Entity<WhateverTheTypeOfResponseIs>()
.Ignore(r => r.MobilePhone);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.