Type confusion in Entity Framework

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
objecta
Posts: 2
Joined: Thu 11 Sep 2008 04:38

Type confusion in Entity Framework

Post by objecta » Thu 11 Sep 2008 05:04

Hi

I'm trying to create a new Entity Datat Model Generated from an exiting database, and I'm having some trouble with datatypes on parametrs not matching the the datatypes on some columns on the tabel.

/*
Server version : 5.0.51b-community-nt
*/
/*Table structure for table `defaultmenuitems` */

CREATE TABLE `defaultmenuitems` (
`MenuID` int(11) NOT NULL,
`ItemID` int(11) NOT NULL,
`MenuText` varchar(50) default NULL,
`WebPage` varchar(50) default NULL,
`ParentID` int(11) default NULL,
`ShowIt` tinyint(1) default NULL,
`Auth` tinyint(4) default NULL,
PRIMARY KEY (`MenuID`,`ItemID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

The two coluoms with the problems is ShowIt and Auth. Both are "translated" into type SByte when the data model is created.

I have 3 stored procedures (CRUD):

CREATE PROCEDURE `defaultmenuitemsAdd`( `?menuID` int, `?menuText` varchar(50), `?webPage` varchar(50), `?parentID` int, `?showIt` tinyint(1), `?auth` tinyint )
BEGIN
INSERT INTO defaultmenuitems (
MenuID,
MenuText,
WebPage,
ParentID,
ShowIt,
Auth
) VALUES (
`?MenuID`,
`?MenuText`,
`?WebPage`,
`?ParentID`,
`?ShowIt`,
`?Auth`
);
select LAST_INSERT_ID();

CREATE PROCEDURE `defaultmenuitemsUpdate`( `?menuID` int, `?itemID` int, `?menuText` varchar(50), `?webPage` varchar(50), `?parentID` int, `?showIt` tinyint(1), `?auth` tinyint )
UPDATE defaultmenuitems SET
MenuID = `?MenuID`,
MenuText = `?MenuText`,
WebPage = `?WebPage`,
ParentID = `?ParentID`,
ShowIt = `?ShowIt`,
Auth = `?Auth`
WHERE
ItemID = `?ItemID`;

CREATE PROCEDURE `defaultmenuitemsDelete`( `?itemID` int )
DELETE FROM defaultmenuitems
WHERE
ItemID = `?ItemID`;

Below is the generated Model1.edmx (in XML)











































































































The funny thing is the both the p_auth and p_showit paramters is of tinyint type in the function import, but in the table field mapping they have the type of SByte. When I try to do the Stored Procedure Mapping for the CRUD functions I get a build error saying:

Error 2042: Parameter Mapping specified is not valid. The type 'Edm.SByte' of member 'Auth' in type 'tvsyddbModel.defaultmenuitems' is not compatible with 'CoreLab.MySql.tinyint' of parameter 'p_auth' in function 'tvsyddbModel.Store.defaultmenuitemsAdd'.

Error 2042: Parameter Mapping specified is not valid. The type 'Edm.SByte' of member 'Auth' in type 'tvsyddbModel.defaultmenuitems' is not compatible with 'CoreLab.MySql.tinyint' of parameter 'p_auth' in function 'tvsyddbModel.Store.defaultmenuitemsUpdate'.

Error 2042: Parameter Mapping specified is not valid. The type 'Edm.SByte' of member 'ShowIt' in type 'tvsyddbModel.defaultmenuitems' is not compatible with 'CoreLab.MySql.tinyint' of parameter 'p_showit' in function 'tvsyddbModel.Store.defaultmenuitemsAdd'.

Error 2042: Parameter Mapping specified is not valid. The type 'Edm.SByte' of member 'ShowIt' in type 'tvsyddbModel.defaultmenuitems' is not compatible with 'CoreLab.MySql.tinyint' of parameter 'p_showit' in function 'tvsyddbModel.Store.defaultmenuitemsUpdate'.

I wonder why the Data Model Generator is able to map the field type correctly, when mapping the table, but not when the Function paramters is mapped?

objecta

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 25 Sep 2008 14:21

The problem is fixed. The next build will be available in several days.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 29 Sep 2008 13:40

The new build of MyDirect .NET version 4.85.36 is available!
Please visit http://devart.com/forums/viewtopic.php?t=12983

objecta
Posts: 2
Joined: Thu 11 Sep 2008 04:38

Post by objecta » Thu 02 Oct 2008 19:23

Thank You very much

Will give it try right away.

Objecta

Post Reply