Table of Contents

Class EfModelAnalyzer

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

Infrastructure implementation for advanced Entity Framework model analysis using Roslyn and semantic models.

public class EfModelAnalyzer : IEfModelAnalyzer
Inheritance
EfModelAnalyzer
Implements
Inherited Members

Constructors

EfModelAnalyzer(ICompilationFactory, IFileSystem, IEntityFileDiscovery)

Infrastructure implementation for advanced Entity Framework model analysis using Roslyn and semantic models.

public EfModelAnalyzer(ICompilationFactory compilationFactory, IFileSystem fileSystem, IEntityFileDiscovery entityFileDiscovery)

Parameters

compilationFactory ICompilationFactory

The factory for creating Roslyn compilations.

fileSystem IFileSystem

The file system abstraction for reading source files.

entityFileDiscovery IEntityFileDiscovery

The service for discovering entity-related source files.

Methods

AnalyzeContextAsync(string, string?)

Analyzes an Entity Framework DbContext file to extract entity and relationship information.

public Task<EfModel> AnalyzeContextAsync(string path, string? contextName)

Parameters

path string

The file path to the DbContext class.

contextName string

Optional name of the specific context to analyze. If null, the first context found is used.

Returns

Task<EfModel>

A Task<TResult> that resolves to an EfModel containing entities and relationships.

Exceptions

AnalysisException

Thrown when DbContext is not found in the file or semantic symbol cannot be resolved.

See Also

AnalyzeSnapshotAsync(string, string?)

Analyzes an Entity Framework ModelSnapshot file to extract entity and relationship information.

public Task<EfModel> AnalyzeSnapshotAsync(string snapshotPath, string? snapshotName)

Parameters

snapshotPath string

The file path to the ModelSnapshot class.

snapshotName string

Optional name of the specific snapshot to analyze. If null, the first snapshot found is used.

Returns

Task<EfModel>

A Task<TResult> that resolves to an EfModel containing entities and relationships.

Exceptions

AnalysisException

Thrown when ModelSnapshot is not found in the file or semantic symbol cannot be resolved.

See Also

DiscoverDbContexts(SyntaxNode)

Discovers all DbContext classes in the provided syntax tree.

public IEnumerable<string> DiscoverDbContexts(SyntaxNode root)

Parameters

root SyntaxNode

The root SyntaxNode to analyze.

Returns

IEnumerable<string>

A collection of DbContext class names found in the syntax tree.

See Also

DiscoverModelSnapshots(SyntaxNode)

Discovers all ModelSnapshot classes in the provided syntax tree.

public IEnumerable<string> DiscoverModelSnapshots(SyntaxNode root)

Parameters

root SyntaxNode

The root SyntaxNode to analyze.

Returns

IEnumerable<string>

A collection of ModelSnapshot class names found in the syntax tree.

See Also