简体   繁体   English

如何在Entity Framework 7中将实体映射到表?

[英]How do you do map an entity to an table in Entity Framework 7?

I use to use the following configuration to map an entity to a table with Entity Framework. 我曾经使用以下配置将entity映射到带有Entity Framework的表。

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<User>().ToTable("Users");
}

But in Entity Framework 7 the function ToTable no longer exist. 但是在Entity Framework 7中,功能ToTable不再存在。 Does anyone has a solution for this? 有人对此有解决方案吗?

Try using below method: 尝试使用以下方法:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.Entity<SomeClass>().ForRelational().Table(tableName: "Test", schemaName: "Map");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在实体框架中,您将如何对联接表进行“ IN”查询? - In the entity framework, how would you do an “IN” query on a joined table? 如何在实体框架中将一个实体映射到许多实体? - How do I map one entity to many entities in Entity Framework? 您如何在Entity Framework 5中执行SELECT nonExistentColumn? - How do you do a SELECT nonExistentColumn in Entity Framework 5? 如何使用 Entity Framework Core 进行全文搜索? - How do you do fulltext search with Entity Framework Core? 您如何在实体框架的数据库级别执行复杂的“或”过滤器? - How do you do complex "OR" filters at the database level in Entity Framework? 如果数据库没有链接表,如何在Entity Framework中创建多对多关系? - How do you create a many-to-many relationship in Entity Framework if the database doesn't have a linking table? 如何使用Entity Framework代码优先映射带有复合键的继承表? - How do I map an inherited table with a composite key using Entity Framework code-first? 如何使用LINQ和实体框架6进行表联接? - How do I do a table join using LINQ and entity framework 6? 如何使用Entity Framework保存对导航属性的更改 - How do you save changes to navigation properties using Entity Framework 如何在实体框架中更新导航属性? - How do you update navigation properties in entity framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM