[英]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.我的数据库中有几个表,我不希望 EntityFramework 为其创建类。 How can I tell EF to ignore certain tables?
如何告诉 EF 忽略某些表?
I am not that familiar with configuring EF.我对配置 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"
我们告诉 EF 查看我们的数据库并创建/更改 POCO 的方式是运行 Nuget 命令行“Scaffold-DbContext”一个连接字符串“Microsoft.EntityFrameworkCore.SqlServer -DataAnnotations -Force -OutputDir Data”
Is there a way to tell EF to ignore specific tables?有没有办法告诉 EF 忽略特定表?
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 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.