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

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

问题描述

有谁知道如何更改映射数据库表的一个实体在EF4(实体框架4)?

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

后来编辑:我想我找到那里的表名被定义的地方,在模型浏览器。但是,他们的名字是只读的,所以它不可能使用设计器进行编辑。另外,有没有参考(从我所搜索),以表名XML模式。

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. 开启EDMX文件的XML编辑器。
  2. 在它找到SSDL部分。
  3. 找到例如实体集元素< EntitySet的名称=客户的EntityType =ExampleModel.Store.Customers模式=DBO/>
  4. 添加表=MyTableName属性。 < EntitySet的名称=客户的EntityType =ExampleModel.Store.Customers模式=DBO表=MyTableName/>
  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" />

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

希望有所帮助。

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

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