Entity framework 获取外键关系信息
ModelBuilder允许您声明实体之间的关系,但我们需要一种在运行时获取所有关系信息的方法。我们需要生成JSON来表达POCO之间的关系Entity framework 获取外键关系信息,entity-framework,Entity Framework,ModelBuilder允许您声明实体之间的关系,但我们需要一种在运行时获取所有关系信息的方法。我们需要生成JSON来表达POCO之间的关系 relationships = { oneToOne: [{ type: Person, hasKey: "id", hasOne: "ldapAccount", ofType: LdapAccount,
relationships = {
oneToOne: [{
type: Person,
hasKey: "id",
hasOne: "ldapAccount",
ofType: LdapAccount,
withKey: "id",
withForeignKey: "id",
withOne: "person"
}],
oneToMany: [{
type: Company,
hasKey: "id",
hasMany: "agencyRoles",
ofType: AgencyRole,
withKey: "id",
withForeignKey: "companyId",
withOne: "company"
}],
manyToMany: [{
type: PermissionGroup,
hasKey: "id",
hasForeignKey: "permissionId",
hasMany: "permissions",
ofType: Permission,
withKey: "id",
withForeignKey: "permissionGroupId",
withMany: "permissionGroups",
usingMappingType: PermissionGroupToPermission
}]
};
有人知道如何在运行时从上下文检索关系信息吗?这里的答案可能会有所帮助?那很有用,谢谢。