更新 EF4 中的外键约定
我有一个 EF 代码优先数据库。
我有几个实体:
- 客户和
- 订单
,其中订单引用客户
IE
public class Orders
{
public Guid Id {get; set;}
public Customer Customer {get; set}
//snip...
}
数据库
- 这生成了一个包含两个表客户
- 订单的
,其中订单有一个字段 Customer_id 我需要将此字段重命名为 客户 ID。
我知道我可以绘制它,但我希望这是一个约定。
我看过这个页面 http://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.conventions%28v=vs.103%29.aspx 但我不是清楚这些约定的含义。
我正在使用 SqlServer 2008。
I've got a EF code first database.
I've got a couple of entities:
- customer and
- orders
where Orders references Customer
IE
public class Orders
{
public Guid Id {get; set;}
public Customer Customer {get; set}
//snip...
}
This generated a DB with two tables
- Customer
- Orders
where Orders has a field Customer_id I need to have this field renamed to CustomerId.
I know I can map it, but I'd like this to be a convention.
I've looked at this page http://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.conventions%28v=vs.103%29.aspx but I'm not clear on what these conventions all mean.
I'm using SqlServer 2008.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Customer_id 由 EF 约定生成。
您必须声明一个外键并使用数据注释来关联它。
Customer_id is generated by EF convention.
You have to declare a foreign key and use data annotation to associate it.