Migration script does not generate NUMBER with precision and scale

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
gger
Posts: 2
Joined: Fri 13 Jul 2018 05:54

Migration script does not generate NUMBER with precision and scale

Post by gger » Thu 23 Sep 2021 06:14

Hi,
After migration to efcore 5, new migrations does not include correct datatype for number types it misses precision and scale, and it does not take into account configured ColumnType.
Previously we could add ColumnType in entity configuration and migration script would generate correct sql.
Now it does not matter if we add Precision or ColumnType to configuration, or annotation on class property.

I'm using these commands
* dotnet ef migrations add
* dotnet ef migrations script

For example we have :

public class FundValue
{
[Column(TypeName = "NUMBER(19, 2)")]
public decimal? NewVa { get; set; }
...
}

internal class FundValueEntityTypeConfiguration : IEntityTypeConfiguration<FundValue>
{
public void Configure(EntityTypeBuilder<FundValue> c)
{
c.ToTable("FundValue", "APP");
c.Property(e => e.NewVa).HasPrecision(19, 2); // does not affect generated migration script
c.Property(e => e.NewVa).HasColumnType("NUMBER(19, 2)"); // does not affect generated migration script

Generated migration - see type is "decimal" and not customized with HasColumnType
public partial class dddd0 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "NewVa",
schema: "APP",
table: "FundValue",
type: "decimal", // at least we can modify here
precision: 19,
scale: 2,
nullable: true);
}
Snapshot
modelBuilder.Entity("App.FundValues.FundValue", b =>
{
b.Property<decimal?>("NewVa")
.HasPrecision(19, 2)
.HasColumnType("decimal");


Generated script - NewVa is NUMBER, however it should be NUMBER(19,2) :
-- Script was generated by Devart dotConnect for Oracle, Version 9.14.1312
-- Product home page: http://www.devart.com/dotconnect/oracle
-- Database version: Oracle 19.0.0.0
-- Script date 2021-09-23 08:52:19
*******removed ***
END;/
START TRANSACTION;
/
ALTER TABLE APP."FundValue"
ADD "NewVa" NUMBER NULL/
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210923054609_dddd0', '5.0.10')/
COMMIT;
/

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

Re: Migration script does not generate NUMBER with precision and scale

Post by Shalex » Thu 23 Sep 2021 16:13

Thank you for your report.

Mapping of System.Decimal to Oracle NUMBER with specified precision and scale in EF Core 5 is supported. We will notify you when a new public build of dotConnect for Oracle is available for download.

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

Re: Migration script does not generate NUMBER with precision and scale

Post by Shalex » Thu 30 Sep 2021 14:26

New build of dotConnect for Oracle 9.14.1353 is available for download now: viewtopic.php?f=1&t=48280.

Post Reply