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
compilationFactoryICompilationFactoryThe factory for creating Roslyn compilations.
fileSystemIFileSystemThe file system abstraction for reading source files.
entityFileDiscoveryIEntityFileDiscoveryThe 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
pathstringThe file path to the DbContext class.
contextNamestringOptional 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
snapshotPathstringThe file path to the ModelSnapshot class.
snapshotNamestringOptional 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
rootSyntaxNodeThe 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
rootSyntaxNodeThe root SyntaxNode to analyze.
Returns
- IEnumerable<string>
A collection of ModelSnapshot class names found in the syntax tree.
- See Also