This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Verify.EntityFramework extends the Verify snapshot testing framework to support Entity Framework testing. It provides utilities for snapshot testing EF operations including change tracking, query execution, and SQL recording.
The repository contains two main packages:
- Verify.EntityFramework - For EF Core (modern)
- Verify.EntityFrameworkClassic - For EF 6 (legacy)
# Build the solution
dotnet build src
# Run tests (excludes integration tests by default)
dotnet test src
# Run a specific test
dotnet test src --filter "FullyQualifiedName~CoreTests.Added"
# Run tests in a specific project
dotnet test src/Verify.EntityFramework.Testssrc/
├── Verify.EntityFramework/ # EF Core library
│ ├── VerifyEntityFramework.cs # Main public API
│ ├── Converters/ # JSON converters for EF objects
│ │ ├── QueryableConverter.cs # Converts IQueryable to SQL + results
│ │ ├── TrackerConverter.cs # Converts ChangeTracker state
│ │ └── LogEntryConverter.cs # Recorded SQL entries
│ └── LogCommandInterceptor.cs # DbCommandInterceptor for SQL recording
│
├── Verify.EntityFramework.Tests/ # EF Core tests
├── Verify.EntityFrameworkClassic/ # EF 6 library
└── Verify.EntityFrameworkClassic.Tests/
Tests use [ModuleInitializer] to call VerifyEntityFramework.Initialize(model) once at assembly load, passing an IModel from a DbContext. This caches navigation property information for later use.
-
Converters - Custom JSON converters inherit from
WriteOnlyJsonConverter<T>and are registered globally viaVerifierSettings.RegisterFileConverter()or added toDefaultContractResolver.Converters. -
Recording System -
LogCommandInterceptorimplementsDbCommandInterceptorto capture SQL operations. Enable viabuilder.EnableRecording()onDbContextOptionsBuilder. -
Queryable Verification - When verifying an
IQueryable, generates both a.txtfile (query results) and a.sqlfile (the SQL query).
Initialize(IModel)- Required setup, caches model metadataAllData()- DbContext extension to enumerate all database entitiesIgnoreNavigationProperties()- Exclude EF navigation properties from serializationEnableRecording()- Enable SQL command recording on DbContextOptionsBuilderDisableRecording()- Stop recording for a specific context instanceUseDescriptiveTableAliases()- Replace single-char SQL table aliases with full table names via customISqlAliasManagerFactoryScrubInlineEfDateTimes()- Sanitize DateTime values in SQL
- Uses NUnit with
[Parallelizable(ParallelScope.All)] - Snapshot files follow pattern:
TestClass.TestMethod.verified.txt - Async tests use
await Verify(...)pattern - Tests create in-memory SQLite databases or use SQL Server LocalDB
- .NET 10.0 SDK (preview features enabled)
- C# language version: preview
- Key packages: Verify, Microsoft.EntityFrameworkCore, NUnit