GithubHelp home page GithubHelp logo

Comments (3)

roji avatar roji commented on June 1, 2024

I'm not sure why a RenameColumn operation is getting generated there in the migration - that shouldn't be the case; there's no actual change on the database side here, since xmin is a system column that always has that name and cannot be renamed (as the error message says).

You should be able to just remove the RenameColumn operation from the scaffolded migration and work as usual; to fully understand what's going on I'd need to have a full repro, with the migration snapshot before the migration was added, the full set of instructions, etc. I'm not sure it's worth going into this at this point, unless we see lots of other people running into it...

from efcore.pg.

mshwf avatar mshwf commented on June 1, 2024

Thanks @roji for the support, much appreciated.
I now see why this is confusing, it was hard to reproduce, so I made a clone of the actual project and stripped it down to the slimmest structure, so it contains only the bits that are related to the database. Here is the repo I created (README contains the repro steps):
https://github.com/mshwf/npgsql-rename-xmin-issue

Hope it helps!

from efcore.pg.

mshwf avatar mshwf commented on June 1, 2024

I think I found why this behavior happens with me...
In the OnModelCreating I convert column names to lowercase:

var entityTypes = modelBuilder.Model.GetEntityTypes();
var entityProperties = entityTypes.SelectMany(e => e.GetProperties()).ToList();

foreach (var prop in entityProperties)
{
    var colName = prop.GetColumnName(StoreObjectIdentifier.Table(GetTableName(prop)!, GetSchemaName(prop)!));
    prop.SetColumnName(colName?.ToLower());
}

This includes the new version column as well, so, all I needed is to skip this column:

var entityTypes = modelBuilder.Model.GetEntityTypes();
var entityProperties = entityTypes.SelectMany(e => e.GetProperties()).ToList();

foreach (var prop in entityProperties)
{
    // Concurrency tokens are system columns that we shouldn't try to alter their letter-casing
    if (prop.IsConcurrencyToken) continue;
    var colName = prop.GetColumnName(StoreObjectIdentifier.Table(GetTableName(prop)!, GetSchemaName(prop)!));
    prop.SetColumnName(colName?.ToLower());
}

from efcore.pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.