Problem with Timestamp

Problem with Timestamp

Postby denkhe » Fri 14 Jan 2011 13:53

I have the following table in my MySQL database :

Code: Select all
CREATE TABLE IF NOT EXISTS Benutzer (
Id            INTEGER        PRIMARY KEY     AUTO_INCREMENT,
Login         VARCHAR(20)    NOT NULL,
Nachname      VARCHAR(50)    NOT NULL,
Vorname       VARCHAR(50)    NOT NULL,
Timestamp     TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
)


In my Visual Studio 2010-edmx the field Timestamp has the following atrributes:

Code: Select all
StoreGeneratedPattern Computed
Type                           DateTime


On inserting a new record into the table I get the following exception:

Devart.Data.MySql.MySqlException: Incorrect datetime value: '0001-01-01 00:00:00' for column 'Timestamp' at row 1.

I need the Timestamp-field to handle concurrency issues.

Version of Devart.Data.MySql.Entity is 6.0.86.0.
Im am using Visual Studio 2010.

Any suggestions?

Best regards
Heiko Denk
denkhe
 
Posts: 14
Joined: Mon 03 Jan 2011 15:33

Postby AndreyR » Mon 17 Jan 2011 11:41

Could you please open the .edmx file in any XML Editor and check that the SSDL part of the model contains the correct StoreGeneratedPattern attribute?
The annotation:StoreGeneratedPattern attribute form CSDL does not influence the code generation, and the property in this case is available in the insert statement.
However, I have performed the tests for MySQL 5.1.40 and 5.0.87, and failed to reproduce the issue. What is the exact version of your MySQL server?
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby denkhe » Tue 18 Jan 2011 07:49

Thank you for your help.

It is working if I add StoreGeneratedPattern="Computed" to the SSDL-Part of the model.

On problem still remains. If I update the Model from database the paramater is gone.

My Version of MySQL is 5.5.8.


Best regards
Heiko Denk
denkhe
 
Posts: 14
Joined: Mon 03 Jan 2011 15:33

Postby AndreyR » Tue 18 Jan 2011 09:22

The reason of this behaviour is the feature of the Microsoft Update Model from Database wizard.
It overwrites the Storage part of the model by design.
You can either manually add the attribute after each update, or, as an alternative, you can add Devart Entity model to your project (Add New Item->Devart Entity model).
It has the same functionality as the Microsoft models do, but in addition it has a more convenient designer (Devart Entity Developer, it is integrated in Visual Studio), and our wizards do not regenerate the storage by default.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby denkhe » Tue 18 Jan 2011 12:16

I used the Devart Entity model, applied the same changes and now it is working.

One small problem remains. I changed the Name of the entity class (Properties->General->Name) to a different name, which worked fine.

Unfortunately the name is overriden each time I update the model.

Is there a solution to this?
denkhe
 
Posts: 14
Joined: Mon 03 Jan 2011 15:33

Postby AndreyR » Wed 19 Jan 2011 18:08

Thank you for the report, I have reproduced the situation.
I will let you know about the results of our investigation.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby AndreyR » Mon 04 Apr 2011 13:15

The problem with the name overwriting was fixed. Could you please try the latest 6.10.126 build of dotConnect for MySQL?
Please notify us if the error persists.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for MySQL