Database First, but only a subset of the database

I am creating an asp.net6 web application that will divert transactional data from an existing database. There are many lookup tables inside the database that I don't need. I can import the database using ef dbcontext scaffold, but I get all the tables in the database. Is there a way to select and select the tables I want? I can delete all the lookup tables, but if I ever need to update any of them and I use it ef dbcontext scaffold, will it pull out all the tables again?

+4
source share
2 answers

Yes, you can. I have been looking for a solution to the problem in the past for a long time. Parameters ef dbcontext scaffoldare not well documented. Solution as a parameter -t several times :

dnx ef dbcontext scaffold ... -t dbo.Users -t dbo.UserPosts

I described the use in ef dbcontext scaffoldmore detail in the answer . It contains a link to a note on a design project .

UPDATED: Starting with .NET Core RC2, you should use dotnet ef dbcontext scaffold instead dnx ef dbcontext scaffold.

+5
source

For EF core 2.0 you can:

Scaffold-DbContext -Connection "Connection String" -Povider "Microsoft.EntityFrameworkCore.SqlServer" -OutputDir Models -Tables "Table1", "Table2", "Table3", "TableN"
0
source

Source: https://habr.com/ru/post/1625356/


All Articles