在EF4中更改db表名称(实体框架4) [英] Change db table name in EF4 (entity framework 4)

查看:111
本文介绍了在EF4中更改db表名称(实体框架4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何更改EF4(实体框架4)中实体的映射db表?



稍后编辑:我想我已经找到了在模型浏览器中定义了表名称。但是他们的名字是readonly,所以不可能使用设计器来编辑它们。另外,在xml模式中没有引用(从我搜索到的)到表名。

解决方案

如果你只是需要更改表的名称:


  1. 使用XML编辑器打开EDMX文件。


  2. 定位实体集元素,例如< EntitySet Name =CustomersEntityType =ExampleModel.Store.CustomersSchema = dbo/>

  3. 添加 Table =MyTableName属性。 < EntitySet Name =CustomersEntityType =ExampleModel.Store.CustomersSchema =dboTable =MyTableName/>

这是一个完整的 CSDL,SSDL,MSL规范



希望有所帮助。


Does anyone know how to change the mapped db table for an entity in EF4 (entity framework 4)?

Later edit: I think i've found the place where the table names are defined, in the model browser. But their names are readonly, so it's not possible to edit them using the designer. Also, there's no reference (from what i've searched) to the table name in the xml schema.

解决方案

If you just need to change the name of the table you can:

  1. Open EDMX file with XML Editor.
  2. Locate SSDL section in it.
  3. Locate entity set element for example <EntitySet Name="Customers" EntityType="ExampleModel.Store.Customers" Schema="dbo" />.
  4. Add Table="MyTableName" attribute. <EntitySet Name="Customers" EntityType="ExampleModel.Store.Customers" Schema="dbo" Table="MyTableName" />

Here is a complete CSDL, SSDL, MSL specification.

Hope that helps.

这篇关于在EF4中更改db表名称(实体框架4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆