Fluent Property Ignores Don't Work on Interfaces or Inherited Classes
See original GitHub issueDescribe the bug If you a base class, or interface, that describes columns for entities, then use the Fluent interface to ignore properties in that class, it won’t ignore them. Using attributes will.
To Reproduce For the entity:
public class MyTest {
public string MyField { get;set;}
}
public class MyInheritedEntity : MyTest {
}
And the configuration
Configuration.Setup().ForContext<ApplicationDbContext>(config =>
config.ForEntity<MyTest>(x => x
.Ignore(y => y.MyField)
)
);
The field MyField will be included in the changes even though it should not be.
Expected behavior MyField should not be included in the changes section.
Libraries (specify the Audit.NET extensions being used including version): For example:
- Audit.EntityFramework: 14.0.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Fluent Nhibernate AutoMapping Inheritance and Ignoring ...
Now i am trying to auto map the inherited relationship, it automatically maps the abstract property to the child classes, but this is...
Read more >Problems with joinedsubclass
Making an override for one of the derived classes (to use ignore property as per your recommendation yesterday) the ignoreproperty doesnt work, the...
Read more >Inherited property cannot be excluded or included when ...
When a derive class implements an interface through an inherited property, the property cannot be excluded by .Excluding() or included by .
Read more >Fluent API - Configuring and Mapping Properties and Types
This article is designed to demonstrate how to use the fluent API to configure properties. The code first fluent API is most commonly...
Read more >[Webinar Recording] Mistake-Proof Your Code with Fluent ...
Our guest Scott Lilly will walk you through the topic of fluent interfaces and demonstrate how it can save you from needing to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can see the reasons why this would add alot of extra bulk to the project. Thanks for thinking it through and considering it.
I still don’t feel this is something worth implementing.
The entity classes (in your case the derived classes) can be configured explicitly one by one, just like you do for EF or any other ORM framework. I see no advantage in providing such mechanism (inheritance and precendence of property attributes) for classes that just represents entities in a relational database.
Still open to validate and eventually merge any pull request you want to contribute.
Regards