Bug #45077 Insert problem with Connector/NET 6.0.3 and entity framework

Submitted: 25 May 2009 19:08 Modified: 10 Aug 2009 16:21
Reporter: Guido Müller Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.0.3 OS:Any
Assigned to: CPU Architecture:Any

[25 May 2009 19:08] Guido Müller
Description:
Insert into two tables fails with an exception 

The value given is not an instance of type 'Edm.Int32'

How to repeat:
Create two tables:

CREATE TABLE `tab1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;

CREATE TABLE `tab2` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tab1id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_tab2_1` (`tab1id`),
CONSTRAINT `FK_tab2_1` FOREIGN KEY (`id`) REFERENCES `tab1` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; 

Run this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MySQLTest
{
class Program
{
static void Main(string[] args)
{
using (db1Entities ctx = new db1Entities())
{
var tab1Row = new tab1();
tab1Row.name = "test";
ctx.AddTotab1(tab1Row);
ctx.SaveChanges();
Console.WriteLine("New row inserted into tab1 with id " + tab1Row.id);

var tab2Row = new tab2();
tab2Row.tab1 = tab1Row;
ctx.AddTotab2(tab2Row);
ctx.SaveChanges();
Console.WriteLine("New row inserted into tab2 with id " + tab2Row.id);
}

using (db1Entities ctx = new db1Entities())
{
var tab2Row = new tab2();
var tab1Row = ctx.tab1.First();
tab2Row.tab1 = tab1Row;
ctx.AddTotab2(tab2Row);
ctx.SaveChanges();
Console.WriteLine("New row inserted into tab2 with id " + tab2Row.id);
}
}
}
} 

Suggested fix:
N/A
[25 May 2009 19:11] Guido Müller
A second is needed to reproduce the failure.

A model must be created using e.g. by using the Visual Studio tool.
[10 Aug 2009 15:37] Reggie Burnett
fixed in 6.0.5 and 6.1.1
[10 Aug 2009 16:21] Tony Bedford
An entry was added to the 6.0.5 and 6.1.1 changelogs:

Insert into two tables failed when using the Entity Framework. The exception generated was:

The value given is not an instance of type 'Edm.Int32'
[11 Aug 2009 6:25] Tonci Grgin
Bug#45175 was marked as duplicate of this report.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.