简体   繁体   English

如何让实体框架不为某些表创建类?

[英]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.

相关问题 如何使用Entity Framework 6在运行时创建数据库和表? - How can I create a database and tables at runtime using Entity Framework 6? 如何在Entity Framework中创建由外键组成的复合主键? - How can I create a composite primary key consisting of foreign keys to two tables in Entity Framework? 如何从实体框架实体(对象)创建列表? - How can I create a List off of an Entity Framework entity (object)? 如何使用与Entity Framework一起使用表的存储过程 - How can I use a stored procedure that uses tables with Entity Framework 如何使用实体框架获取数据库表的数量? - How can I use entity framework to get a count of database tables? 如何使用实体框架处理可选表? - How can I deal with optional tables using Entity Framework? 如何通过Entity Framework验证表之间的所有关系? - how I can verify all the releations between tables by Entity Framework? 实体框架代码优先:如何在两个表之间创建一对多和一对一的关系? - Entity Framework Code First: How can I create a One-to-Many AND a One-to-One relationship between two tables? 如何在实体框架核心中制作动态查询过滤器? - How can I make a dynamic query filter in entity framework core? 如何使Entity Framework映射成为DbDataReader? - How can I make Entity Framework map a DbDataReader?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM