EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

Bath update can't support mysql

Open lechengbo opened this issue 7 years ago • 13 comments

In efcore, I use Z.EntityFramework.Plus.EFCore.dll in myproject, When I use “Db.Set<Student>().Where(st=>st.Id==1).Update(student=>new Student() { Name= tempName});” it give me a error;description:MySqlException: Duplicate column name 'Id'; I keep watch on Mysql,it produce sql :

     UPDATE `Student` AS A

INNER JOIN ( SELECT st.Id, st.Address, st.Age, st.BirthDay, st.CourceIds, st.CourceList, st.IsDeleted, st.Name, st.Phone, st.Id, st.Family_FatherName, st.Family_MotherName FROM Student AS st WHERE st.Id = 1 ) AS B ON A.Id = B.Id SET A.Name = 'rober20180912172602'

lechengbo avatar Sep 12 '18 09:09 lechengbo

Hello @lechengbo ,

Please let me know about:

  • Entity Framework Core version
  • MySQL database provider & version

Best Regards,

Jonathan

JonathanMagnan avatar Sep 13 '18 00:09 JonathanMagnan

Hello @lechengbo ,

Please let me know about:

  • Entity Framework Core version
  • MySQL database provider & version

Best Regards,

Jonathan

Entity Framework Core version:2.1 MySQL database version:5.7.22-log MySQL database provider:Pomelo.EntityFrameworkCore.MySql 2.1.2

lechengbo avatar Sep 13 '18 00:09 lechengbo

Hello @lechengbo ,

My developer made some test but he never successfully reproduce the issue.

Do you think you could provide a sample project example/test with this issue?

It will help my developer investigate the issue more efficiently.

Best Regards.

Jonathan

JonathanMagnan avatar Oct 01 '18 17:10 JonathanMagnan

Hello @JonathanMagnan , Please see the attachment 1 2 3 4

5

lechengbo avatar Oct 08 '18 07:10 lechengbo

Hello @lechengbo ,

We will need a projects sample with the issue.

We already tried to reproduce it with similar configurations and we didn't have the error. So if you wish we continue to investigate and fix the issue, you will need to create a project and provide us an example that throws the error.

Best Regards,

Jonathan

JonathanMagnan avatar Oct 08 '18 19:10 JonathanMagnan

Hello @JonathanMagnan , I found the problem;Please see the project and attachment; but I can't upload the project files,you should fix the issue

lechengbo avatar Oct 11 '18 07:10 lechengbo

hello @JonathanMagnan when the class have another class,the error will throw

lechengbo avatar Oct 11 '18 08:10 lechengbo

Hello @lechengbo ,

I'm not sure why you cannot upload the file, maybe a GitHub restriction on something in your files. Could you upload it somewhere else such as OneDrive and provide us the link?

JonathanMagnan avatar Oct 11 '18 12:10 JonathanMagnan

Hello @JonathanMagnan Please see the link https://www.roberg.cn/otherfiles/bathupdatefail.rar https://www.roberg.cn/otherfiles/6.png

lechengbo avatar Oct 13 '18 03:10 lechengbo

Hello @lechengbo ,

The current link doesn't look to work. We get a 404 error when trying to download your project.

JonathanMagnan avatar Oct 15 '18 00:10 JonathanMagnan

Hello @JonathanMagnan Sorry, Please the link ,it can work. https://www.roberg.cn/OtherFiles/BatchUpdateFail.rar

6

lechengbo avatar Oct 15 '18 08:10 lechengbo

Thank you @lechengbo ,

The task has been assigned to one of my developers.

JonathanMagnan avatar Oct 16 '18 02:10 JonathanMagnan

Hello,

Just to let you know that we are not sure currently what to do. The issue might not be on our side but on Pomelo

For example,

This LINQ var test = db.Student.Where(x => x.Name.Contains("rober") ).ToList();

Provide the following SQL

SELECT  `x`.`Id` , `x`.`Address` , `x`.`Age` , `x`.`BirthDay` , 
`x`.`CreatedTime`, `x`.`IsDeleted`, `x`.`Name`, `x`.`Phone`, 
`x`.`Id`, `x`.`Family_FatherName`, `x`.`Family_MotherName`
FROM `Student` AS `x` WHERE LOCATE( 'rober' ,  `x`.`Name`) > 0

As you will notice, the Id is here twice and our library has not been used at all.

We are supposed to fully review the Batch Update and Batch Delete next month, perhaps we will find something to handle this.

JonathanMagnan avatar Oct 22 '18 00:10 JonathanMagnan