Home > Net >  How to get only specific tables to create models from database with Entity Framework Core in C#
How to get only specific tables to create models from database with Entity Framework Core in C#

Time:04-02

I'm using Scaffold-DbContext to create models from an existing database, but it auto pluralizes the table names and I don't want that. It also gets all the tables but I need only a couple of them.

Is there a way to disable pluralization and select only some specific tables with that command?

CodePudding user response:

If you have a look at the official documentation - you'd see:

Scaffold-DbContext

Parameters

...

  • Tables <String[]> - The tables to generate entity types for. If this parameter is omitted, all tables are included.

...

  • NoPluralize - Don't use the pluralizer. Added in EF Core 5.0.

So yes - both of your requests can be handled with parameters to Scaffold-DbContext - just consult the docs!

  • Related