Mapping Bool mysql data types
Re: Mapping Bool mysql data types
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:
Should have been:
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.
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")]
Code: Select all
[Column(Storage = "_AllowOrderDiscount", CanBeNull = false, DbType = "TINYINT(3) NOT NULL")]
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.
Re: Mapping Bool mysql data types
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.
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.
Re: Mapping Bool mysql data types
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.
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.
Re: Mapping Bool mysql data types
We still couldn't reproduce this issue. With dotConnect for MySQL Pro 6.60.258 version and later, we get:
instead of:
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.
Code: Select all
[Column(Storage = "_Prop1", CanBeNull = false, DbType = "TINYINT(3) NOT NULL")]
Code: Select all
[Column(Storage = "_Prop1", CanBeNull = false, DbType = "BOOLEAN NOT NULL")]
- 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.