Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Error generating column type #58

Closed
tdabek opened this issue Mar 6, 2019 · 3 comments
Closed

Error generating column type #58

tdabek opened this issue Mar 6, 2019 · 3 comments
Labels
released Issue is resolved in a current release

Comments

@tdabek
Copy link

tdabek commented Mar 6, 2019

Hello,

I believe there is an error in generating column type. Setting different value than default produces duplicated HasColumnType call in EF Core:

modelBuilder.Entity<Test>()  
                     .Property(t => t.Template)  
                     .IsRequired()  
                     .HasColumnType("json");  
                     .HasColumnType("json");

The problem is with EFCoreDesigner.ttinclude file, line 331 and 332:

if (modelAttribute.ColumnType != "default")
            segments.Add($"HasColumnType(\"{modelAttribute.ColumnType}\");");

These lines should be removed, because in 335:

if (modelAttribute.ColumnType.ToLowerInvariant() != "default")
         {
            if (modelAttribute.ColumnType.ToLowerInvariant() == "varchar" || modelAttribute.ColumnType.ToLowerInvariant() == "char")
               segments.Add($"HasColumnType(\"{modelAttribute.ColumnType}({modelAttribute.MaxLength})\")");
            else
               segments.Add($"HasColumnType(\"{modelAttribute.ColumnType}\")");
         }

Removing these two lines from EFCoreDesigner.ttinclude on my local machine solved this issue.

@msawczyn
Copy link
Owner

msawczyn commented Mar 29, 2019

Thanks for the report ... and the PR for the fix! I'll have that in the next release.

@msawczyn msawczyn added bug Confirmed bug pending release Issue is resolved in the current codebase, will be published with the next release labels Mar 29, 2019
@msawczyn msawczyn added released Issue is resolved in a current release and removed bug Confirmed bug pending release Issue is resolved in the current codebase, will be published with the next release labels Apr 16, 2019
@msawczyn
Copy link
Owner

1.2.7 pre-release is in the releases. Could you take a peek and see if this resolves your issue? Thanks!

@msawczyn
Copy link
Owner

Fixed and released in 1.2.7.1. Closing issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
released Issue is resolved in a current release
Projects
None yet
Development

No branches or pull requests

2 participants