Skip to content

Add docs for renaming tables/columns #5105

@SoftCircuits

Description

@SoftCircuits

I'd like to rename a table in Entity Framework Core, code first. I do not want to drop and create the table, as this would lose all my data. As I search for information on this, I see that the vast majority of it is outdated.

This best source I found is by Mitchel Sellers. But this also seems outdated. I'm not sure how much difference it makes but he declares his table as:

public DbSet Widgets { get; set; }

When the modern construct seems to use generics:

public DbSet<Widget> Widgets { get; set; }

I also found several articles that recommend entering the migration code manually. But I don't think this is ideal. I know if it's done correctly, all the associated constraint names are renamed as well. I would prefer not to enter the migration manually.

Why doesn't Microsoft publish the current and correct steps to do this?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions