-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Bug Report
Environment
EntityFrameworkCore.Ydb" Version="0.0.1"
"Ydb.Sdk.Yc.Auth" Version="0.2.0"
"Microsoft.EntityFrameworkCore" Version="9.0.5"
"Microsoft.EntityFrameworkCore.Design" Version="9.0.5"
"Microsoft.EntityFrameworkCore.Relational" Version="9.0.5"
dotnet-ef Tool 'dotnet-ef' (version '9.0.5')
Current behavior:
Steps to reproduce:
dotnet ef migrations add migration_000 -s Web -p DataAccess
result:
/// <inheritdoc />
public partial class migration_000 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "Int32", nullable: false)
.Annotation("YdbSerial", true),
Title = table.Column<string>(type: "Text", nullable: false),
WeightG = table.Column<decimal>(type: "Decimal(22, 9)", nullable: false),
DateCreated = table.Column<DateTime>(type: "Timestamp", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Products");
}
}
dotnet ef database update -s Web -p DataAccess
raises an exception:
System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AppDbContext' has pending changes. Add a new migration before updating the database.
I've seen that is is recommended to
.ConfigureWarnings(warnings => warnings.Ignore(RelationalEventId.PendingModelChangesWarning))
but calling
dotnet ef migrations add migration_001 -s Web -p DataAccess
and
dotnet ef migrations add migration_002 -s Web -p DataAccess
and so on creates the following migration constantly
/// <inheritdoc />
public partial class migration_001 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<decimal>(
name: "WeightG",
table: "Products",
type: "Decimal(22, 9)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "Decimal(22, 9)(22, 9)");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<decimal>(
name: "WeightG",
table: "Products",
type: "Decimal(22, 9)(22, 9)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "Decimal(22, 9)");
}
}
Expected behavior:
I guess that oldType: "Decimal(22, 9)(22, 9)"); is not correct. And all works perfectly without decimals. I do not even need to suppress PendingModelChangesWarning.
Related code:
public class Product
{
public int Id { get; set; }
public required string Title { get; set; }
public decimal WeightG { get; set; }
public DateTime DateCreated { get; set; }
}
This is not critical but annoying.
Still thank you so much for EntityFrameworkCore.Ydb.Extensions. Great job!