Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when updating-from-query in TPH: "The destination column could not be found" (EF6) #315

Closed
cjmairair opened this issue Feb 10, 2018 · 5 comments
Assignees

Comments

@cjmairair
Copy link

cjmairair commented Feb 10, 2018

Example of problem:

Let's say I have a base class, Animal, and there are different subclasses, in an EF TPH (Table per Hierarchy) setup.

var age = 123;
context.Animals.Where(...).Update(a => new Animal() { Age = age });  // throws Exception

The exception is "The destination column could not be found: age".

FYI: The property name "age" is the same as the column name in the DB ("age").

So, after reading Issue #238 , I though that my problem would be fixed by downloading the latest version:

Z.EntityFramework.Plus.EF6.dll - 1.7.14.0
Z.EntityFramework.Extensions.dll - 3.14.7.0

But it's not.

I also tried novamxd's forked code (from his repository) (see Issue #245), which supposedly fixed this problem, but it doesn't.

I know that this problem is related to "updating from query" and not "batch updating", but still, I was hoping that novamxd's code would fix this.

@cjmairair cjmairair changed the title Error when updating-from-query in TPH: "The destination column could not be found" Error when updating-from-query in TPH: "The destination column could not be found" (EF6) Feb 10, 2018
@JonathanMagnan JonathanMagnan self-assigned this Feb 11, 2018
@JonathanMagnan
Copy link
Member

Hello @cjmairair ,

Thank you for reporting,

We will try this scenario this week and see what's missing.

Best Regards,

Jonathan

@ch-rob
Copy link

ch-rob commented Jun 1, 2018

+1 Same issue...

DbSet.Where(whereClause).Update(update);
where update is {p => new AssetFileRecord() {NetProceeds = Round(1.1, 2)}}

AssetFileRecord (our base class in the hierarchy) contains NetProceeds, as does the child class. This worked until I made AssetFileRecord part of a TPH hierarchy.

  • EF6
  • .Net 4.6.2
  • Z.EntityFramework.Plus.EF6 1.7.19

@JonathanMagnan
Copy link
Member

Hello @cjmairair , @ch-rob ,

We have made some great progress to support base type for TPH.

We made a solution and all our unit tests are currently running.

We will clean the code and release a new version tomorrow at the end of the day.

Best Regards,

Jonathan

@JonathanMagnan
Copy link
Member

Hello @cjmairair , @ch-rob ,

The v1.8.0 has been released.

A lot of files has been added/modified for reading the model, so make sure to report me errors if something occurs.

Best Regards,

Jonathan

@JonathanMagnan
Copy link
Member

Hello @cjmairair , @ch-rob ,

This issue will be closed since it has been resolved.

Feel free to reopen it if you feel otherwise.

Best Regards,

Jonathan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants