dotnet / dotnet/EntityFramework.Docs

Add docs for renaming tables/columns

Open
#5,105 11 comments 0 reactions 0 assignees View on GitHub
area-migrations
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

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](https://www.mitchelsellers.com/blog/article/renaming-tables-safely-in-entity-framework-core). 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 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.