I am creating an asp.net6 web application that will pull back transactional data from an existing database. Inside the database we have a lot of lookup tables that I don't have a need for. I am able to import the database with
ef dbcontext scaffold but I get all the tables in the database. Is there a way to pick and choose the tables I want? I can delete all the lookup tables but if I ever have to update any of them and I use the
ef dbcontext scaffold will it pull all the tables again?
Yes you can. I searched a long time for the solution of the problem in the past. The options of
ef dbcontext scaffold are documented not good enough. The solution as the using
-t parameter multiple times:
dnx ef dbcontext scaffold ... -t dbo.Users -t dbo.UserPosts
UPDATED: Starting with .NET Core RC2 one should use dotnet ef dbcontext scaffold instead of
dnx ef dbcontext scaffold.
For EF core 2.0 you shoud do :
Scaffold-DbContext -Connection "Connection String" -Povider "Microsoft.EntityFrameworkCore.SqlServer" -OutputDir Models -Tables "Table1", "Table2", "Table3", "TableN"