Page 1 of 1

BUG: wrong sql-type (when copying and pasting properties)

Posted: Tue 23 Feb 2021 04:06
by RobertK
How to reproduce issue

1. Create a class model in the Entity Developer, standalone program.
2. Add primary key and prosperities as you normally would, add a column "myitem" with data type int32.
3. Copy "myitem" to "sku"
4. change "sku" to data type string.
5. Generate the class model code and you will find the data type is incorrect.

If you have a look inside the efml you will find entity developer saved this xml with the wrong sql-type

Code: Select all

    <property name="Sku" type="String" p1:nullable="True" p1:ValidateRequired="false" p1:Guid="5236fc66-aaea-4f6f-8ca7-fa132b9e841b">
      <column name="" not-null="False" sql-type="int4" p1:unicode="False" />
    </property>
sql-type should be "varchar" because its a string.

Code: Select all

    <property name="Sku" type="String" p1:nullable="True" p1:ValidateRequired="false" p1:Guid="5236fc66-aaea-4f6f-8ca7-fa132b9e841b">
      <column name="" not-null="False" sql-type="varchar" p1:unicode="False" />
    </property>
Work around: remove the column and create a new column or manually update the efml file and change the sql-type from int4 to varchar

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Tue 23 Feb 2021 19:18
by Shalex
We cannot reproduce the issue with Entity Developer v6.10.1189. Please upgrade.
1. Create a class model in the Entity Developer, standalone program.
1. You work with Devart EF Core Model (*.efml) and SQL Server, don't you?
2. Add primary key and prosperities as you normally would, add a column "myitem" with data type int32.
2. Did you set SQL Type (via Column Editor) for "myitem" explicitly? If yes, what value?
4. change "sku" to data type string.
4.1. Did you change SQL Type for "sku" explicitly?
4.2. Did you run Regenerate Storage and Mapping?

If possible, send us a test model for reproducing the issue.

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Thu 25 Feb 2021 16:39
by RobertK
im using postgres and ef core template, standalone entity developer

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Thu 25 Feb 2021 18:31
by Shalex
We still cannot reproduce the issue.

1. Did you change SQL Type for "sku" explicitly?
2. Did you run Regenerate Storage and Mapping?
3. Please send us a test model for reproducing the issue.

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Sun 28 Feb 2021 09:52
by RobertK
Shalex wrote: Thu 25 Feb 2021 18:31 We still cannot reproduce the issue.

1. Did you change SQL Type for "sku" explicitly?
2. Did you run Regenerate Storage and Mapping?
3. Please send us a test model for reproducing the issue.
1. Yes, thats correct
2. No, I did not, I just regenerated the code for class models
3. Download from here https://filebin.net/5bz15qlz87r2e146 (it contains the issue)
4. Generate the class models. You will find that NewCol is a string in Entity Developer but it generates an int when the code is generated.

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Sun 28 Feb 2021 09:55
by RobertK
You can also check ApplicationDbContext, the NewCol is a string but in ApplicationDbContext it is an int

NewCol was copied from "Order" and renamed to "NewCol" with it's data type changed from int to string.

Copying and pasting and changing the data type does not work, you might assume it works because the model shows you everything is correct but the generated code is incorrect.

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Mon 01 Mar 2021 18:05
by Shalex
RobertK wrote: Sun 28 Feb 2021 09:55 NewCol was copied from "Order" and renamed to "NewCol" with it's data type changed from int to string.
The current code generation corresponds to the model settings. Please open Property Editor for the NewCol property, press [...] against Column to open Column Editor, change SQL Type from int4 to varchar.

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Wed 03 Mar 2021 15:01
by RobertK
Shalex wrote: Mon 01 Mar 2021 18:05
RobertK wrote: Sun 28 Feb 2021 09:55 NewCol was copied from "Order" and renamed to "NewCol" with it's data type changed from int to string.
The current code generation corresponds to the model settings. Please open Property Editor for the NewCol property, press [...] against Column to open Column Editor, change SQL Type from int4 to varchar.
Unable to find SQL Type.

what is this button [...] ?

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Thu 04 Mar 2021 09:08
by Shalex
Please see the screenshot: https://prnt.sc/10cscgq. The [...] button should open Column Editor. Does this help?

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Fri 05 Mar 2021 04:46
by RobertK
Shalex wrote: Thu 04 Mar 2021 09:08 Please see the screenshot: https://prnt.sc/10cscgq. The [...] button should open Column Editor. Does this help?
thanks, is there a feature where it could check data type is string and sql data type is varchar, if it is incorrect then tell me?

Re: BUG: wrong sql-type (when copying and pasting properties)

Posted: Fri 05 Mar 2021 13:42
by Shalex
If you specified SQL Type manually, you should change it manually as well. Or you can leave SQL Type blank to exclude .HasColumnType(...) from mapping.

JIC: you can run Regenerate Storage and Mapping to clear SQL Type values in all properties
RobertK wrote: is there a feature where it could check data type is string and sql data type is varchar, if it is incorrect then tell me?
Thank you for your suggestion. We will investigate the possibility of generating a warning.