Page 1 of 1

Maping to decimal - precision/scale ignored

Posted: Fri 30 Jul 2021 09:25
by Adaƛ
Hi,

for some reason my setting from mapping are ignored while script is generated.

Code:

Code: Select all

            builder.Property(x => x.Rate)
                .HasColumnType("DECIMAL")
                .HasPrecision(10, 4);
Generated script:

Code: Select all

CREATE TABLE Vat ( 
  Id int AUTO_INCREMENT UNIQUE NOT NULL,
  Name varchar(50) NULL,
  Rate decimal(58,29) NOT NULL,
  CreatedDate datetime NOT NULL,
  ModifiedDate datetime NOT NULL,
  IsActive bit(1) NOT NULL,
  PRIMARY KEY (Id)
);
Why there is decimal(58,29)?
Any idea how to fix it?

Re: Maping to decimal - precision/scale ignored

Posted: Tue 03 Aug 2021 09:50
by Shalex
Thank you for your report. We have reproduced the issue with context.Database.EnsureCreated() and will notify you when it is fixed.

Re: Maping to decimal - precision/scale ignored

Posted: Thu 30 Sep 2021 14:33
by Shalex
Mapping of System.Decimal to MySQL DECIMAL with specified precision and scale in EF Core 5 is supported.

Refer to viewtopic.php?f=2&t=48276.