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

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Tue 23 Feb 2021 04:06

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

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

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

Post by Shalex » Tue 23 Feb 2021 19:18

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.

RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Thu 25 Feb 2021 16:39

im using postgres and ef core template, standalone entity developer

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

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

Post by Shalex » 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.

RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Sun 28 Feb 2021 09:52

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.
Last edited by RobertK on Mon 01 Mar 2021 09:06, edited 1 time in total.

RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Sun 28 Feb 2021 09:55

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.

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

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

Post by Shalex » 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.

RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Wed 03 Mar 2021 15:01

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 [...] ?

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

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

Post by Shalex » Thu 04 Mar 2021 09:08

Please see the screenshot: https://prnt.sc/10cscgq. The [...] button should open Column Editor. Does this help?

RobertK
Posts: 109
Joined: Thu 02 Mar 2017 05:44

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

Post by RobertK » Fri 05 Mar 2021 04:46

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?

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

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

Post by Shalex » Fri 05 Mar 2021 13:42

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.

Post Reply