Table of Contents

Class RelationshipAnalyzer

Namespace
ProjGraph.Lib.EntityFramework.Infrastructure
Assembly
ProjGraph.Lib.EntityFramework.dll

Provides methods for analyzing and managing relationships between entities in an Entity Framework model.

public static class RelationshipAnalyzer
Inheritance
RelationshipAnalyzer
Inherited Members

Remarks

The RelationshipAnalyzer class contains static methods to analyze entity relationships, create relationships, determine relationship types, and handle many-to-many relationships by converting them into join tables. It is designed to work with the Entity Framework model and Roslyn's code analysis APIs.

Methods

AnalyzeRelationships(EfModel, Dictionary<string, EfEntity>, Compilation)

Analyzes the relationships between entities in the provided entity framework model and updates the model accordingly.

public static void AnalyzeRelationships(EfModel model, Dictionary<string, EfEntity> entities, Compilation compilation)

Parameters

model EfModel

The EfModel representing the entity framework model to be analyzed and updated.

entities Dictionary<string, EfEntity>

A dictionary containing all entities in the model, keyed by EffectiveKey (the bare name for a root entity, {Owner}.{Nav} for an owned one).

compilation Compilation

The Compilation object used to analyze the entity symbols.

Remarks

This method iterates through all ROOT entities in the model (owned types are excluded — see the walked-source filter below), identifies their relationships, and updates the model with the discovered relationships. It ensures that duplicate relationships are not added by maintaining a set of added relationship keys. Additionally, it converts any many-to-many relationships into join tables.