Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1447

Update with Entity Framework 6 (no replies)

$
0
0
Hello,

I'm using the version 6.8.3.0 of the connector to communicate to my database via Entity Framework 6.

When I try to update a record of a table (the only table in my model), I 've got an exception #1248 "Every derived table must have its own alias".

As I'm using EF I don't write myself the SQL request. I just expect EF is writing a correct request for me.

I don't see how I can correct this. Here is the C# code I use when the error occurs.

private void OnDelete(Message arg)
{
if (arg == null)
{
return;
}

try
{
using (var entities = new GestionEntities())
{
var message = entities.Messages.FirstOrDefault<Message>(m => m.Identifiant == arg.Identifiant);
message.Deleted = true; // not a fysical delete
deletedRowCount = entities.SaveChanges();
}

}
catch (Exception)
{
throw ;
}
}

The code does not seem to be very complex. Can you help me to find a solution ?

To be complete, here is the generated SQL to find the record
SELECT
`Extent1`.`Mes_ID`,
`Extent1`.`Prs_ID`,
`Extent1`.`Mes_DatePosted`,
`Extent1`.`Mes_LastName`,
`Extent1`.`Mes_FirstName`,
`Extent1`.`Mes_Email`,
`Extent1`.`Mes_Phone`,
`Extent1`.`MesContent`,
`Extent1`.`Mes_Handled`,
`Extent1`.`Mes_Deleted`
FROM (SELECT
`tmessage`.`Mes_ID`,
`tmessage`.`Prs_ID`,
`tmessage`.`Mes_DatePosted`,
`tmessage`.`Mes_LastName`,
`tmessage`.`Mes_FirstName`,
`tmessage`.`Mes_Email`,
`tmessage`.`Mes_Phone`,
`tmessage`.`MesContent`,
`tmessage`.`Mes_Handled`,
`tmessage`.`Mes_Deleted`
FROM `tmessage` AS `tmessage`) AS `Extent1`
WHERE `Extent1`.`Mes_ID` = 1 LIMIT 1

Viewing all articles
Browse latest Browse all 1447

Trending Articles