koenbeuk / EntityFrameworkCore.Projectables

Project over properties and functions in your linq queries
MIT License
260 stars 17 forks source link

Auto-configure projectable properties as [NotMapped] #109

Open Bretttt opened 4 weeks ago

Bretttt commented 4 weeks ago

All IEnumerable<> projectable properties have to be marked as [NotMapped] or EF throws an error. Example:

[Projectable]
public IEnumerable<MyThings> MySpecialThings => MyThings.Where(t => t.IsSpecial);

EF appears to be trying to map all properties defined as IEnumerable<> or ICollection<> as navigation properties, even if they are get-only (which, needless to say, includes properties like the above).

I could be convinced otherwise, but I would make the case that all projectable properties will always be unmapped.

It would be nice to have this library iterate through the models as part of model building and call .Ignore(theProjectableProperty)