Ado Entity: Treat Tiny as Boolean = false

只谈情不闲聊 提交于 2019-12-11 11:01:52

问题


I need to connect a .net application to a mysql database. When I add the tables to the model, all the columns with the type Tinyint are mapped like boolean.

After Searching in mysql forum, i add "Treat Tiny As Boolean=false" in the connection string. When I refresh the model, nothing changes. If I change the type manually to Sbyte or Int 16 I get the following error.

Error   43  Error 2019: Member Mapping specified is not valid. The type 'Edm.SByte[Nullable=True,DefaultValue=]' of member 'personacion' in type 'Model.perfiles' is not compatible with 'MySql.usmallint[Nullable=True,DefaultValue=]' of member 'personacion' in type 'Model.Store.perfiles'. C:\Proyectos\StatusXMLGenerator\StatusXMLGenerator\StatusXMLGenerator\Model.edmx    474 17  StatusXMLGenerator
Error   42  Error 2019: Member Mapping specified is not valid. The type 'Edm.Int16[Nullable=False,DefaultValue=]' of member 'id_seccion' in type 'Model.formularios' is not compatible with 'MySql.bool[Nullable=False,DefaultValue=]' of member 'id_seccion' in type 'Model.Store.formularios'.    C:\Proyectos\StatusXMLGenerator\StatusXMLGenerator\StatusXMLGenerator\Model.edmx    454 17  StatusXMLGenerator

The error 42 has also an incorrect mapping. It says that the type of the column is Mysql.Bool, but in the databases, I have stored values from 1 to 10, so it should be Mysql.usmallint, like in error 43.

This is my connection string:

<add name="ModelContainer" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=**********;user id=*******;password=*****;database=pki_2010;persistsecurityinfo=True;Treat Tiny As Boolean=false;&quot;" providerName="System.Data.EntityClient" />

Any ideas?


回答1:


Solved.

If there is anyone on my situation this is the solution.

1º Add "Treat Tiny As Boolean=false" to the connection string.

2º Build to refresh the new value of the connection string

3º Open the model as XML and set the values of the columns to "tinyint" (The schema should be something like:

<edmx><schema><entitycontainer><entitytype><property name="..." type="tinyint">...

4º Open the model with the designer and map the columns to Sbyte

5º Save and build again.



来源:https://stackoverflow.com/questions/23731963/ado-entity-treat-tiny-as-boolean-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!