Dude, I don't mean to be rude, but this code is crap. Obviously, you get paid for the number of lines of code. But if this is not the case, it can be rewritten much shorter. Create a new topic asking for a code review. And be sure to specify the exact version of EF you are using. In EF Core with the help of
EF.Property
method the code can be shortened by an order of magnitude. —
Alexander Petrov 7 secs ago