Bug #46311 TimeStamp table column Entity Framework issue.
Submitted: 20 Jul 17:54 Modified: 11 Aug 15:47
Reporter: Ian Scragg
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:MySQL Client 5.1.11 OS:Other (XP)
Assigned to: Reggie Burnett Target Version:
Tags: connector, entity framework
Triage: D3 (Medium)

[20 Jul 17:54] Ian Scragg
Description:
MySQL Client 5.1.11
Connector/Net 6.1

I have defined timestamp columns in most of my tables for concurency purposes.  I genrate
an entity model in Visual Studio 2008 using the database without issue.  

When querying the database using linq with the following example:

      var user = (from u in Database.user
                  where u.Email == email
                  select u).FirstOrDefault();

The following exception is generated:

The 'Modified' property on 'user' could not be set to a 'DateTime' value. You must set
this property to a non-null value of type 'Byte[]'. 

I have searched the internet for a solution and have found this is a common issues faced
by other developers.

How to repeat:
Consistent issue with the Visual Studio Entity Framework.

Suggested fix:
Example of custom fix involving rebuild of source code:

"I fixed this by compiling my own version and fixing it. 

\MySql\MySql.Data.Entity\Provider\Properties\ProviderManifest.xml 

change timestamp to 
<Type Name="timestamp" PrimitiveTypeKind="DateTime"> 
<FacetDescriptions> 
<Precision DefaultValue="0" Constant="true" /> 
</FacetDescriptions> 
</Type>"

Can be found on this url:
http://forums.mysql.com/read.php?38,255123,261261#msg-261261

This should be fixed in the generic build without outside custom builds.
[21 Jul 15:36] Tonci Grgin
Ian, don't know... Need to deal with backlog and then make test for this...
[7 Aug 14:00] Tonci Grgin
Hi Ian. Looking into latest sources I see what you refer to:
- <Type Name="timestamp" PrimitiveTypeKind="Binary">
- <FacetDescriptions>
  <MaxLength DefaultValue="19" Constant="true" /> 
  <FixedLength DefaultValue="true" Constant="true" /> 
  </FacetDescriptions>
  </Type>

As this section is neither logical nor in sync with "timestamp" section I've decided to
set the report to Verified by looking into code and would be most interested why is
PrimitiveTypeKind="Binary" if it's not a bug.
[7 Aug 14:02] Tonci Grgin
Examined file is trunk\MySql.Data.Entity\Provider\Properties\ProviderManifest.xml.
[10 Aug 23:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80487

746 Reggie Burnett	2009-08-10
      - fixed timestamp columns with entity framework (bug #46311)
[10 Aug 23:19] Reggie Burnett
fixed in 6.0.5 and 6.1.1
[11 Aug 9:35] Ian Scragg
Thank you for resolving this issue quickly.
[11 Aug 15:47] Tony Bedford
An entry was added to the 6.0.5 and 6.1.1 changelogs:

An exception was generated when using TIMESTAMP columns with the Entity Framework.