EF Code First prevent property mapping with Fluent API

c# ef-code-first entity-framework fluent-interface

Accepted Answer

ZZZ_tmp
27
5/23/2017 12:17:29 PM

Popular Answer

Unfortunately, the accepted solution does not work, especially if the child class is not an entity and not the least with EF6.

There doesn't seem to be a fluent API method for doing this. It only functions when data annotations are used:

public class AddressDetails
{
    public string City { get; set; }

    [NotMapped]
    public string Country { get; set; }
    // other properties
}

Note: If there is an instance whereCountry should only be omitted if it is a component of another entity; otherwise, this strategy is useless.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow