【发布时间】:2015-07-03 22:41:48
【问题描述】:
我是 Entity Framework 的新手,我想在现有数据库和从 Entity Framework(来自 Visual Studio 2013 pro)创建的实体之间进行一些映射。我有一个名为“客户”的表和以下列:
- customer_id
- 客户名称
- 地址
我希望将其翻译成这样的实体:
public partial class Customer {
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public string Address { get; set; }
}
注意类名的大写,以及所有属性的 PascalCase 和没有下划线。
有没有办法做到这一点
- 某种 Visual Studio GUI
- 实体中的注释(如将 db 列“customer_id”映射到属性“CustomerId”)
- 配置文件(例如 xml)
- 另一种方式
请注意,我知道使用代码优先的方法是可能的,但我首先使用数据库。我尝试通过 Visual Studio 的 GUI 编辑 .edmx,但它导致引用丢失(找不到文件 CustomerId.cs),我不知道在哪里编辑此引用。
感谢您的帮助
【问题讨论】:
标签: entity-framework