Bug #46311 TimeStamp table column Entity Framework issue.
Submitted: 20 Jul 2009 15:54 Modified: 11 Aug 2009 13:47
Reporter: Ian Scragg Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:MySQL Client 5.1.11 OS:Other (XP)
Assigned to: Reggie Burnett CPU Architecture:Any
Tags: connector, entity framework

[20 Jul 2009 15: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 2009 13:36] Tonci Grgin
Ian, don't know... Need to deal with backlog and then make test for this...
[7 Aug 2009 12: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 2009 12:02] Tonci Grgin
Examined file is trunk\MySql.Data.Entity\Provider\Properties\ProviderManifest.xml.
[10 Aug 2009 21: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 2009 21:19] Reggie Burnett
fixed in 6.0.5 and 6.1.1
[11 Aug 2009 7:35] Ian Scragg
Thank you for resolving this issue quickly.
[11 Aug 2009 13: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.
[31 Jul 2015 13:33] Neil Hosey
When is this due to be fixed?