Home > Net >  How to Scaffold Database tables in easy way?
How to Scaffold Database tables in easy way?

Time:09-02

I have a database with many tables. I want to scaffold it with my ASP.NET Core 6.0 MVC project. Problem is: I do not want all the tables but only some of them.

Let's say there are 100 tables and I want to scaffold only 40 of them.

I know the command

Scaffold-DbContext "Server=;Database=;user id=;password=;" Microsoft.EntityFrameworkCore.SqlServer 
        -OutputDir -Tables

but in this way, I'd have to write all the tables' name 1 by 1.

Is there an easy way that I can scaffold many tables or is there a command to scaffold the ones starting with an 'a'?

CodePudding user response:

You can specify based on schema using the --schema option or by table using the --table option

https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli#specifying-tables

CodePudding user response:

The EF Core Power Tools have a UI for selecting the tables to scaffold.

  • Related