将外键添加到EDM事后? [英] Add foreign keys to EDM ex post?

查看:110
本文介绍了将外键添加到EDM事后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2010 Beta2中基于SQL服务器数据库构建了我的EDM,定制了实体名称和实体容器名称,但我忘了添加FK。左是否可以通过以下方式添加FK事后巫师?
我没有成功。在我看来,唯一的方法是创建一个新的EDM。但问题是我的自定义丢失了。

解决方案

你好,

你可以使用设计师将现有的独立关联改为FK关联,但这是一个手动过程,您需要应用于每个单独的协会。这个过程,从我的脑海中如下:

1。将FK属性添加到从属实体。
2。将添加的FK映射到商店的基础FK属性。在主体实体的PK和依赖体中的FK属性之间的关联上设置参照约束。删除关联中的 关联集映射。

有关详细信息,请参阅此博客文章: http://blogs.msdn.com/adonet/archive/2009/11/06/foreign-key-relationships-in-the -entity-framework.aspx

感谢,

I build my EDM in VS 2010 Beta2 based on a SQL server DB, customized the entity names and entitycontainer names but I forgot to add the FKs.
Is it possible to add the FK ex post by means of the wizard?
I did not succeed. In my eyes the only way is to create a new EDM. But the problem is that my customizing gets lost then.

解决方案

Hi,

You can change existing independent associations to FK associations using the designer, but it is a manual process you will need to apply to each individual associations. The process, from the top of my mind is as follows:

1. Add the FK property to the dependent entity.
2. Map the added FK to the underlying FK property of the store.
3. Set a referential constraint on the associations, between the PK of the principal entity and the FK property in the dependent.
4. Remove the association set mapping on the association.

For more details, please see this blog post: http://blogs.msdn.com/adonet/archive/2009/11/06/foreign-key-relationships-in-the-entity-framework.aspx

Thanks,
Diego


这篇关于将外键添加到EDM事后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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