Skip to content

Scaffold-DbContext flag to force update (without deleting other entities) #37796

@whit-tj

Description

@whit-tj

What problem are you trying to solve?

I use scaffolding to create EF models for a lot of different databases, some of which I don't own or control in my organization. Because it is database-first, I often need to re-scaffold to update my models to match any table changes, (names/types/sizes).

Example: One table has columns renamed, some columns deleted, some columns added. I can either manually make those changes to match or I can run the Scaffold-DbContext command again with a list of all the tables in my model, and use the -Force flag. Which forcefully updates all of the tables, even though I know only 1 table had any changes. Which could lead to someone missing a table when using the force, which would then cause other issues. Also when doing a scaffold with 200 tables it can take 20+ minutes to run when I really only need to force update 1 specific table.

Describe the solution you'd like

I would like to have a flag that implements the -Force to update the model, but only need to list that 1 table. The new flag would mean: "do not remove entities that already exist, only force update the tables listed"

Perhaps -UpdateOnly

This would be very beneficial for those database-first scenarios, while still allowing use of the scaffolding tool to keep the model in sync with the database, while keeping this fast.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions