efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Be more forgiving on DbContext name for migrations

Open billrob opened this issue 2 years ago • 1 comments

I recently started working with a project that has two DbContext in it. Thus I am typing more -context EmployeeDbContext. In other projects the team uses `EmployeeContext'. I'd like to cut down on the number of characters I have to type to match to a context.

I see the code already does a case insensitive to find a .Single and if not, it further tries to restrict down to a .Single by using exact case. I'd like to add a first pass case where Context and DbContext are added as a suffix to the name. So this would work

add-migration NameOfMigration -context employee

The normal duplicate error message would show if both EmployeeContext and EmployeeDbContext existed.

billrob avatar Jan 26 '23 07:01 billrob

We can consider wildcards here, e.g. -context Employee*. For example, dotnet test --filter allows wildcards for selecting which tests to run.

roji avatar Jan 26 '23 11:01 roji

Note from triage: The PMC commands already support tab-completion, and #5976 covers adding this for the dotnet CLI. We feel this is a better way to go that wildcards, since only one DbContext type can be specified at a time.

ajcvickers avatar Jan 30 '23 10:01 ajcvickers