Mapping Bool mysql data types

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 28 Sep 2011 11:50

It is very difficult to implement your suggestion. We are technically limited to change the EDM Wizard behaviour. We recommend you to create EF model in Entity Developer where the mentioned functionality is implemented.

Miros
Posts: 45
Joined: Thu 20 Jan 2011 10:12
Contact:

Re: Mapping Bool mysql data types

Post by Miros » Tue 19 Jun 2012 09:49

It seems that if you create a LinqConnect Model (.lqml) and set the Connection String parameter "Tiny As Boolean=True", it does not have the desired effect, rather the contrary.

In the XXXDataContext.Designer.cs tinyint columns are mapped as BOOLEAN which gives an error "Invalid Datatype: BOOLEAN" when trying to save entities to database.

Example from XXXXDataContext.Designer.cs:

Code: Select all

[Column(Storage = "_AllowOrderDiscount", CanBeNull = false, DbType = "BOOLEAN NOT NULL")]
Should have been:

Code: Select all

[Column(Storage = "_AllowOrderDiscount", CanBeNull = false, DbType = "TINYINT(3) NOT NULL")]
So, in fact, NOT setting the Connection String parameter "Tiny As Boolean=True" is the solution that seems to work.

I don't know if it is caused by your new datatype mapping options under Tools -> Entity Developer -> Options -> Server Options, where mappings are now specified, but I wanted to bring this to your attention in case you haven't noticed that this is a problem.

In fact the Connection String parameter "Tiny As Boolean=True" works fine with Entity Models (.edml).

I am currently on dotConnect for MySql Professional version 6.60.258.0.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Mapping Bool mysql data types

Post by MariiaI » Wed 20 Jun 2012 13:24

We couldn't reproduce this issue on our environment. Try re-creating the model with changes in the Tools -> Entity Developer -> Options -> Server Options (map the 'tinyint' server type to the 'boolean' .NET type). LinqConnect model creation should not be affected by the presence of 'Tiny As Boolean = True;' parameter in the connection string.

If it doesn't help, please specify the following:
- the version of the MySQL server;
- the type mapping rules for the 'tinyint' type in Tools -> Entity Developer -> Options -> Server Options;
- the exact actions after which the 'DbType = "BOOLEAN NOT NULL"' entry is generated (is it just setting "Tiny As Boolean" to true and saving the model?);
- the template you are working with when creating LinqConnect models;
- if possible, please send us the model you are working with.

Miros
Posts: 45
Joined: Thu 20 Jan 2011 10:12
Contact:

Re: Mapping Bool mysql data types

Post by Miros » Wed 20 Jun 2012 14:22

OK, I did another test, and here is what I did:

1. Right Click project and Add New Item, select Devart LinqConnect Model.
2. Select Database First, Next >
3. Enter connection parameters, select database, click Advanced button, select Tiny As Boolean = True, Next >
4. Select Generate From Database, Next >
5. Choose source, check all for the selected database, Next >
6. Leave Naming rules as-is, Next >
7. Leave Model properties as-is, Next >
8. Select All Entitites, Next >
9. Select LinqConnect template, Next >
10. Finish
11. Open LinqConnect Model and drag tables from Database Explorer onto Diagram.
12. Open DataContext.Designer.cs and search for "BOOLEAN"

Do the _exact_ same as above except not selecting Tiny As Boolean, and observe that "BOOLEAN" is not in DataContext.Designer.cs.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Mapping Bool mysql data types

Post by MariiaI » Thu 21 Jun 2012 12:50

We still couldn't reproduce this issue. With dotConnect for MySQL Pro 6.60.258 version and later, we get:

Code: Select all

[Column(Storage = "_Prop1", CanBeNull = false, DbType = "TINYINT(3) NOT NULL")]
instead of:

Code: Select all

[Column(Storage = "_Prop1", CanBeNull = false, DbType = "BOOLEAN NOT NULL")]
Please send us the model you are working with and specify the following:
- the version of your MySQL server;
- the type mapping rules for the 'tinyint' type in Tools -> Entity Developer -> Options -> Server Options;
- the Server Data Type of the 'tinyint' property of the entity displayed by Entity Developer.

Post Reply