简体   繁体   English

从 EDM model 中查找 Principal 端和 Dependent 端

[英]Find Principal end and Dependent end out of EDM model

I need to find all foreign keys using EDM model.我需要使用 EDM model 找到所有外键。 I was able to pull many useful information using Systm.Data.Entity.Core.Metadata classes and methods but still not able to get Principal and Dependent from an association or relationship.我能够使用 Systm.Data.Entity.Core.Metadata 类和方法提取许多有用的信息,但仍然无法从关联或关系中获取 Principal 和 Dependent。
ReferentialConstraint class has public properties FromRole / ToRole , one of them is Principal and another is Dependent but I'm not sure which ones exactly. ReferentialConstraint class 具有公共属性FromRole / ToRole ,其中一个是 Principal ,另一个是 Dependent 但我不确定哪些是确切的。
ReferentialConstraint has private fields PrincipalEnd and DependentEnd who might help me but I woudn't like to access them via reflection. ReferentialConstraint有私有字段PrincipalEndDependentEnd可能会帮助我,但我不想通过反射访问它们。 Is there a better way to figure out what end is Principal and what end is Dependent?有没有更好的方法来确定什么是 Principal 以及什么是 Dependent?

PS: I saw solution in this EF6 - How to determine principal/dependent sides from a NavigationProperty question but there is no proof it's 100% correct. PS:我在这个EF6 中看到了解决方案 - 如何从 NavigationProperty 问题中确定主体/依赖方,但没有证据证明它是 100% 正确的。

Ok, I finally found source code here好的,我终于在这里找到了源代码

internal AssociationEndMember PrincipalEnd
{
    get { return (AssociationEndMember)FromRole; }
}

internal AssociationEndMember DependentEnd
{
    get { return (AssociationEndMember)ToRole; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法确定主端 - Unable to determine the principal end 无法确定关联的主要目的-实体框架模型优先 - Unable to determine the principal end of an association - Entity Framework Model First 在实例化模型的EF数据库优先方法中,它无法确定类型之间关联的主要终点 - In EF Database First Approach when instantiating a model, it fails to determine the principal end of an association between the types 必须明确配置此关联的主体端 - The principal end of this association must be explicitly configured 实体框架关联结束的主体错误 - Entity Framework principal end of an association error C#无法确定关系的主要结束 - C# Unable to determine the principal end of the relationship 如何找到OData edm模型类型到clr类型的映射? - How to find mapping of OData edm model type to clr type? 无法确定OR的主体结尾“值不能为null,参数名称为'key'” - Unable to determine the principal end of OR “Value cannot be null, parameter name 'key'” 实体框架关系问题“无法确定主要目标……” - Entity framework relationship issue 'Unable to determine the principal end…' 插入多个继承的实体会产生-无法确定关系的主要终点 - Inserting Multiple Inherited Entities Gives - Unable to determine the principal end of the relationship
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM