简体   繁体   中英

How can I make Entity Framework not create a class for some tables?

I have several tables in my DB that I do not want EntityFramework to create classes for. How can I tell EF to ignore certain tables?

I am not that familiar with configuring EF. The way we tell EF to look at our DB and create/change POCOs is by running a Nuget command line of "Scaffold-DbContext "a connection string" Microsoft.EntityFrameworkCore.SqlServer -DataAnnotations -Force -OutputDir Data"

Is there a way to tell EF to ignore specific tables?

You can use the tables or schema switch to explicitly list which tables or schemas (include all tables within the schema) to reverse engineer.

https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding

您可以使用 -Tables 参数指定要包含的表:

Scaffold-DbContext "connection-string" MySql.Data.EntityFrameworkCore -OutputDir dir -Tables table1,table2,table3  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM