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;
/
Migration script does not generate NUMBER with precision and scale
Re: Migration script does not generate NUMBER with precision and scale
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.
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.
Re: Migration script does not generate NUMBER with precision and scale
New build of dotConnect for Oracle 9.14.1353 is available for download now: viewtopic.php?f=1&t=48280.