Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record overwritten when using both MVC app and MS Access against MySQL

Tags:

Some background: We have developed an ASP.NET MVC port of a client's MS Access application. The Application used/uses MySQL as the data store via ODBC. What we're running into is that if the client uses the MS Access application to capture a new record, and soon after the MVC application captures a new record, the MVC application's record seems to overwrite the last record created by the Access application, as well as creating a second record.

So in effect, the Access application's record would look like this at first

ID | NAME | SURNAME
1  | joe  | Schmoe  

but then, when the MVC application creates its one record, this happens:

ID | NAME  | SURNAME
1  | james | smith
2  | james | smith

The MVC application seems to overwrite both the last record captured by Access, as well as creating a new record.

We use Entity Framework 5. All we do to save the record is

var record = new Person(){NAME = "james", SURNAME = "smith"};
db.People.Add(record);
db.SaveChanges();

This type of thing only happens when the client has used the Access application. And it only happens when the last added record is from the Access application and the new record is from the MVC/EF application.

Any input would be appreciated.

When capturing a sequence of records via Access, this does not happen. When capturing a sequence of records via Entity Framework, it does not happen. When capturing first via Entity Framework and THEN Access, this does not happen. It only happens when the sequence is Access first, Entity Framework second.

like image 490
Captain Kenpachi Avatar asked May 11 '17 09:05

Captain Kenpachi


1 Answers

Sorry but there is not enough space to write this in a comment

Some suggestions:

  • The code you posted is not enough to understand the issue. At least you could write all the code that creates/use db (is it just a using before the lines you posted?)

  • Probably the error is when you save from EF. You could start inserting a breakpoint in every SaveChanges even the ones that you are sure that is not called

  • Other thing you can do is to swap MySQL with SQL Server (your app works perfectly also with SQL Server the hardest work is to change the links from Access, EF already works) and check if you have the same issue.

like image 198
bubi Avatar answered Oct 19 '22 23:10

bubi