Skip to content

Migration adds a suffix onto identifers #36306

@BigSquareHasNoEdge

Description

@BigSquareHasNoEdge

Bug description

Migration suffixes "s" for column name and index name;

I have a Far class mapped to "Far" table.

Far table has a column of int "BooId" as FK to Boo.Id and BooId was indexed with name of "IX_Fars_BooId".
I have changed Far class to drop BooId and produce migrations to get a migration class as below:

// Up()
migrationBuilder.DropIndex(
   name: "IX_Fars_BooIds",  // "s" was suffixed
   table: "Fars");

migrationBuilder.DropColumn(
   name: "BooIds", // "s" was suffixed.
   table: "Fars"); 

// Down() has the same namings

As a result, db update failed, until I remove the suffixed "s" in four places.(two in Up() and two in Down())

ef cli tool version is 9.0.4

Your code

// the before code 
class Boo
{
   public int Id { get; protected set; }
   public ICollection<Far> Fars { get; } = [];
}
class Far
{
   public int Id { get; protected set; }
   public int? BooId { get; set; }
}

// after code
class Boo
{
   public int Id { get; protected set; }
   // public ICollection<Far> Fars { get; } = [];
}
class Far
{
   public int Id { get; protected set; }
   // public int? BooId { get; set; }
}

Stack traces

Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such index: IX_Fars_BooIds'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
...

Verbose output


EF Core version

9.0.3

Database provider

Microsoft.EntityFrameworkCore.Sqlite (9.0.3)

Target framework

No response

Operating system

Windows10

IDE

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy