Maping to decimal - precision/scale ignored

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

Maping to decimal - precision/scale ignored

Post by Adaś » Fri 30 Jul 2021 09:25

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?

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

Re: Maping to decimal - precision/scale ignored

Post by Shalex » Tue 03 Aug 2021 09:50

Thank you for your report. We have reproduced the issue with context.Database.EnsureCreated() and will notify you when it is fixed.

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

Re: Maping to decimal - precision/scale ignored

Post by Shalex » Thu 30 Sep 2021 14:33

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.

Post Reply