{"id":18937413,"url":"https://github.com/verifytests/verify.entityframework","last_synced_at":"2025-04-13T07:56:38.317Z","repository":{"id":38410525,"uuid":"232024582","full_name":"VerifyTests/Verify.EntityFramework","owner":"VerifyTests","description":"Extends Verify to allow verification of EntityFramework bits.","archived":false,"fork":false,"pushed_at":"2025-04-09T00:42:10.000Z","size":1225,"stargazers_count":64,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T07:56:30.559Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VerifyTests.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"VerifyTests"}},"created_at":"2020-01-06T04:35:10.000Z","updated_at":"2025-04-09T00:42:13.000Z","dependencies_parsed_at":"2023-12-29T07:23:58.946Z","dependency_job_id":"6eb475f2-5245-4760-960d-1f9fd1504efd","html_url":"https://github.com/VerifyTests/Verify.EntityFramework","commit_stats":{"total_commits":847,"total_committers":8,"mean_commits":105.875,"dds":0.5159386068476978,"last_synced_commit":"6ba47fc64265b7634ed57496a61ddae00aed6372"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.EntityFramework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.EntityFramework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.EntityFramework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.EntityFramework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VerifyTests","download_url":"https://codeload.github.com/VerifyTests/Verify.EntityFramework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681489,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T12:11:04.455Z","updated_at":"2025-04-13T07:56:38.301Z","avatar_url":"https://github.com/VerifyTests.png","language":"C#","funding_links":["https://github.com/sponsors/VerifyTests"],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"/src/icon.png\" height=\"30px\"\u003e Verify.EntityFramework\n\n[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true\u0026label=)](https://github.com/orgs/VerifyTests/discussions)\n[![Build status](https://ci.appveyor.com/api/projects/status/g6njwv0aox62atu0?svg=true)](https://ci.appveyor.com/project/SimonCropp/verify-entityframework)\n[![NuGet Status](https://img.shields.io/nuget/v/Verify.EntityFramework.svg?label=Verify.EntityFramework)](https://www.nuget.org/packages/Verify.EntityFramework/)\n[![NuGet Status](https://img.shields.io/nuget/v/Verify.EntityFrameworkClassic.svg?label=Verify.EntityFrameworkClassic)](https://www.nuget.org/packages/Verify.EntityFrameworkClassic/)\n\nExtends [Verify](https://github.com/VerifyTests/Verify) to allow snapshot testing with EntityFramework.\n\n**See [Milestones](../../milestones?state=closed) for release notes.**\n\n\n## NuGet packages\n\n * https://nuget.org/packages/Verify.EntityFramework/\n * https://nuget.org/packages/Verify.EntityFrameworkClassic/\n\n\n## Enable\n\nEnable VerifyEntityFramework once at assembly load time:\n\n\n### EF Core\n\n\u003c!-- snippet: EnableCore --\u003e\n\u003ca id='snippet-EnableCore'\u003e\u003c/a\u003e\n```cs\nstatic IModel GetDbModel()\n{\n    var options = new DbContextOptionsBuilder\u003cSampleDbContext\u003e();\n    options.UseSqlServer(\"fake\");\n    using var data = new SampleDbContext(options.Options);\n    return data.Model;\n}\n\n[ModuleInitializer]\npublic static void Init()\n{\n    var model = GetDbModel();\n    VerifyEntityFramework.Initialize(model);\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/ModuleInitializer.cs#L5-L22' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-EnableCore' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nThe `GetDbModel` pattern allows an instance of the `IModel` to be stored for use when `IgnoreNavigationProperties` is called inside tests. This is optional, and instead can be passed explicitly to `IgnoreNavigationProperties`.\n\n\n### EF Classic\n\n\u003c!-- snippet: EnableClassic --\u003e\n\u003ca id='snippet-EnableClassic'\u003e\u003c/a\u003e\n```cs\n[ModuleInitializer]\npublic static void Init() =\u003e\n    VerifyEntityFrameworkClassic.Initialize();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFrameworkClassic.Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-EnableClassic' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Recording\n\nRecording allows all commands executed by EF to be captured and then (optionally) verified.\n\n\n### Enable\n\nCall `EfRecording.EnableRecording()` on `DbContextOptionsBuilder`.\n\n\u003c!-- snippet: EnableRecording --\u003e\n\u003ca id='snippet-EnableRecording'\u003e\u003c/a\u003e\n```cs\nvar builder = new DbContextOptionsBuilder\u003cSampleDbContext\u003e();\nbuilder.UseSqlServer(connection);\nbuilder.EnableRecording();\nvar data = new SampleDbContext(builder.Options);\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L384-L391' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-EnableRecording' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n`EnableRecording` should only be called in the test context.\n\n\n### Usage\n\nTo start recording call `EfRecording.StartRecording()`. The results will be automatically included in verified file.\n\n\u003c!-- snippet: Recording --\u003e\n\u003ca id='snippet-Recording'\u003e\u003c/a\u003e\n```cs\nvar company = new Company\n{\n    Name = \"Title\"\n};\ndata.Add(company);\nawait data.SaveChangesAsync();\n\nRecording.Start();\n\nawait data\n    .Companies\n    .Where(_ =\u003e _.Name == \"Title\")\n    .ToListAsync();\n\nawait Verify();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L483-L501' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Recording' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003c!-- snippet: CoreTests.RecordingTest.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.RecordingTest.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  ef: {\n    Type: ReaderExecutedAsync,\n    HasTransaction: false,\n    Text:\nselect c.Id,\n       c.Name\nfrom   Companies as c\nwhere  c.Name = N'Title'\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.RecordingTest.verified.txt#L1-L11' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.RecordingTest.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\nSql entries can be explicitly read using `EfRecording.FinishRecording`, optionally filtered, and passed to Verify:\n\n\u003c!-- snippet: RecordingSpecific --\u003e\n\u003ca id='snippet-RecordingSpecific'\u003e\u003c/a\u003e\n```cs\nvar company = new Company\n{\n    Name = \"Title\"\n};\ndata.Add(company);\nawait data.SaveChangesAsync();\n\nRecording.Start();\n\nawait data\n    .Companies\n    .Where(_ =\u003e _.Name == \"Title\")\n    .ToListAsync();\n\nvar entries = Recording.Stop();\n//TODO: optionally filter the results\nawait Verify(\n    new\n    {\n        target = data.Companies.Count(),\n        entries\n    });\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L639-L664' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-RecordingSpecific' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### DbContext spanning\n\n`StartRecording` can be called on different DbContext instances (built from the same options) and the results will be aggregated.\n\n\u003c!-- snippet: MultiDbContexts --\u003e\n\u003ca id='snippet-MultiDbContexts'\u003e\u003c/a\u003e\n```cs\nvar builder = new DbContextOptionsBuilder\u003cSampleDbContext\u003e();\nbuilder.UseSqlServer(connectionString);\nbuilder.EnableRecording();\n\nawait using var data1 = new SampleDbContext(builder.Options);\nRecording.Start();\nvar company = new Company\n{\n    Name = \"Title\"\n};\ndata1.Add(company);\nawait data1.SaveChangesAsync();\n\nawait using var data2 = new SampleDbContext(builder.Options);\nawait data2\n    .Companies\n    .Where(_ =\u003e _.Name == \"Title\")\n    .ToListAsync();\n\nawait Verify();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L451-L474' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-MultiDbContexts' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\u003c!-- snippet: CoreTests.MultiDbContexts.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.MultiDbContexts.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  ef: [\n    {\n      Type: ReaderExecutedAsync,\n      HasTransaction: false,\n      Parameters: {\n        @p0 (Int32): 0,\n        @p1 (String): Title\n      },\n      Text:\nset implicit_transactions off;\n\nset nocount on;\n\ninsert  into Companies (Id, Name)\nvalues                (@p0, @p1)\n    },\n    {\n      Type: ReaderExecutedAsync,\n      HasTransaction: false,\n      Text:\nselect c.Id,\n       c.Name\nfrom   Companies as c\nwhere  c.Name = N'Title'\n    }\n  ]\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.MultiDbContexts.verified.txt#L1-L28' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.MultiDbContexts.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Disabling Recording for an instance\n\n\u003c!-- snippet: RecordingDisableForInstance --\u003e\n\u003ca id='snippet-RecordingDisableForInstance'\u003e\u003c/a\u003e\n```cs\nvar company = new Company\n{\n    Name = \"Title\"\n};\ndata.Add(company);\nawait data.SaveChangesAsync();\n\nRecording.Start();\n\nawait data\n    .Companies\n    .Where(_ =\u003e _.Name == \"Title\")\n    .ToListAsync();\ndata.DisableRecording();\nawait data\n    .Companies\n    .Where(_ =\u003e _.Name == \"Disabled\")\n    .ToListAsync();\n\nawait Verify();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L510-L533' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-RecordingDisableForInstance' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\u003c!-- snippet: CoreTests.RecordingDisabledTest.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.RecordingDisabledTest.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  ef: {\n    Type: ReaderExecutedAsync,\n    HasTransaction: false,\n    Text:\nselect c.Id,\n       c.Name\nfrom   Companies as c\nwhere  c.Name = N'Title'\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.RecordingDisabledTest.verified.txt#L1-L11' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.RecordingDisabledTest.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## ChangeTracking\n\nAdded, deleted, and Modified entities can be verified by performing changes on a DbContext and then verifying the instance of ChangeTracking. This approach leverages the [EntityFramework ChangeTracker](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.changetracking.changetracker).\n\n\n### Added entity\n\nThis test:\n\n\u003c!-- snippet: Added --\u003e\n\u003ca id='snippet-Added'\u003e\u003c/a\u003e\n```cs\n[Test]\npublic async Task Added()\n{\n    var options = DbContextOptions();\n\n    await using var data = new SampleDbContext(options);\n    var company = new Company\n    {\n        Name = \"company name\"\n    };\n    data.Add(company);\n    await Verify(data.ChangeTracker);\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L87-L103' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Added' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003c!-- snippet: CoreTests.Added.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.Added.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  Added: {\n    Company: {\n      Id: 0,\n      Name: company name\n    }\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.Added.verified.txt#L1-L8' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.Added.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Deleted entity\n\nThis test:\n\n\u003c!-- snippet: Deleted --\u003e\n\u003ca id='snippet-Deleted'\u003e\u003c/a\u003e\n```cs\n[Test]\npublic async Task Deleted()\n{\n    var options = DbContextOptions();\n\n    await using var data = new SampleDbContext(options);\n    data.Add(new Company\n    {\n        Name = \"company name\"\n    });\n    await data.SaveChangesAsync();\n\n    var company = data.Companies.Single();\n    data.Companies.Remove(company);\n    await Verify(data.ChangeTracker);\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L105-L124' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Deleted' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003c!-- snippet: CoreTests.Deleted.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.Deleted.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  Deleted: {\n    Company: {\n      Id: 0\n    }\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.Deleted.verified.txt#L1-L7' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.Deleted.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Modified entity\n\nThis test:\n\n\u003c!-- snippet: Modified --\u003e\n\u003ca id='snippet-Modified'\u003e\u003c/a\u003e\n```cs\n[Test]\npublic async Task Modified()\n{\n    var options = DbContextOptions();\n\n    await using var data = new SampleDbContext(options);\n    var company = new Company\n    {\n        Name = \"old name\"\n    };\n    data.Add(company);\n    await data.SaveChangesAsync();\n\n    data.Companies.Single()\n        .Name = \"new name\";\n    await Verify(data.ChangeTracker);\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L126-L146' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Modified' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003c!-- snippet: CoreTests.Modified.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.Modified.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  Modified: {\n    Company: {\n      Id: 0,\n      Name: {\n        Original: old name,\n        Current: new name\n      }\n    }\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.Modified.verified.txt#L1-L11' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.Modified.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Queryable\n\nThis test:\n\n\u003c!-- snippet: Queryable --\u003e\n\u003ca id='snippet-Queryable'\u003e\u003c/a\u003e\n```cs\nvar queryable = data.Companies\n    .Where(_ =\u003e _.Name == \"company name\");\nawait Verify(queryable);\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L341-L347' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Queryable' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified files:\n\n\n### EF Core\n\n\n#### CoreTests.Queryable.verified.txt\n\n\u003c!-- snippet: CoreTests.Queryable.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.Queryable.verified.txt'\u003e\u003c/a\u003e\n```txt\n[\n  {\n    Name: company name\n  }\n]\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.Queryable.verified.txt#L1-L5' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.Queryable.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n#### CoreTests.Queryable.verified.sql\n\n\u003c!-- snippet: CoreTests.Queryable.verified.sql --\u003e\n\u003ca id='snippet-CoreTests.Queryable.verified.sql'\u003e\u003c/a\u003e\n```sql\nSELECT [c].[Id], [c].[Name]\nFROM [Companies] AS [c]\nWHERE [c].[Name] = N'company name'\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.Queryable.verified.sql#L1-L3' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.Queryable.verified.sql' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### EF Classic\n\n\n#### ClassicTests.Queryable.verified.txt\n\n\u003c!-- snippet: ClassicTests.Queryable.verified.txt --\u003e\n\u003ca id='snippet-ClassicTests.Queryable.verified.txt'\u003e\u003c/a\u003e\n```txt\nSELECT \n    [Extent1].[Id] AS [Id], \n    [Extent1].[Content] AS [Content]\n    FROM [dbo].[Companies] AS [Extent1]\n    WHERE N'value' = [Extent1].[Content]\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFrameworkClassic.Tests/ClassicTests.Queryable.verified.txt#L1-L5' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ClassicTests.Queryable.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## AllData\n\nThis test:\n\n\u003c!-- snippet: AllData --\u003e\n\u003ca id='snippet-AllData'\u003e\u003c/a\u003e\n```cs\nawait Verify(data.AllData())\n    .AddExtraSettings(\n        serializer =\u003e\n            serializer.TypeNameHandling = TypeNameHandling.Objects);\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L320-L327' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-AllData' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file with all data in the database:\n\n\u003c!-- snippet: CoreTests.AllData.verified.txt --\u003e\n\u003ca id='snippet-CoreTests.AllData.verified.txt'\u003e\u003c/a\u003e\n```txt\n[\n  {\n    $type: Company,\n    Id: 1,\n    Name: Company1\n  },\n  {\n    $type: Company,\n    Id: 4,\n    Name: Company2\n  },\n  {\n    $type: Company,\n    Id: 6,\n    Name: Company3\n  },\n  {\n    $type: Company,\n    Id: 7,\n    Name: Company4\n  },\n  {\n    $type: Employee,\n    Id: 2,\n    CompanyId: 1,\n    Name: Employee1,\n    Age: 25\n  },\n  {\n    $type: Employee,\n    Id: 3,\n    CompanyId: 1,\n    Name: Employee2,\n    Age: 31\n  },\n  {\n    $type: Employee,\n    Id: 5,\n    CompanyId: 4,\n    Name: Employee4,\n    Age: 34\n  }\n]\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.AllData.verified.txt#L1-L43' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-CoreTests.AllData.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## IgnoreNavigationProperties\n\n`IgnoreNavigationProperties` extends `SerializationSettings` to exclude all navigation properties from serialization:\n\n\u003c!-- snippet: IgnoreNavigationProperties --\u003e\n\u003ca id='snippet-IgnoreNavigationProperties'\u003e\u003c/a\u003e\n```cs\n[Test]\npublic async Task IgnoreNavigationProperties()\n{\n    var options = DbContextOptions();\n\n    await using var data = new SampleDbContext(options);\n\n    var company = new Company\n    {\n        Name = \"company\"\n    };\n    var employee = new Employee\n    {\n        Name = \"employee\",\n        Company = company\n    };\n    await Verify(employee)\n        .IgnoreNavigationProperties();\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L148-L170' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-IgnoreNavigationProperties' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Ignore globally\n\n\u003c!-- snippet: IgnoreNavigationPropertiesGlobal --\u003e\n\u003ca id='snippet-IgnoreNavigationPropertiesGlobal'\u003e\u003c/a\u003e\n```cs\nvar options = DbContextOptions();\nusing var data = new SampleDbContext(options);\nVerifyEntityFramework.IgnoreNavigationProperties();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L198-L204' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-IgnoreNavigationPropertiesGlobal' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## WebApplicationFactory\n\nTo be able to use [WebApplicationFactory](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.testing.webapplicationfactory-1) for [integration testing](https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests) an identifier must be used to be able to retrieve the recorded commands. Start by enable recording with a unique identifier, for example the test name or a GUID:\n\n\u003c!-- snippet: EnableRecordingWithIdentifier --\u003e\n\u003ca id='snippet-EnableRecordingWithIdentifier'\u003e\u003c/a\u003e\n```cs\nprotected override void ConfigureWebHost(IWebHostBuilder webBuilder)\n{\n    var dataBuilder = new DbContextOptionsBuilder\u003cSampleDbContext\u003e()\n        .EnableRecording(name)\n        .UseSqlite($\"Data Source={name};Mode=Memory;Cache=Shared\");\n    webBuilder.ConfigureTestServices(\n        _ =\u003e _.AddScoped(\n            _ =\u003e dataBuilder.Options));\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L593-L605' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-EnableRecordingWithIdentifier' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nThen use the same identifier for recording:\n\n\u003c!-- snippet: RecordWithIdentifier --\u003e\n\u003ca id='snippet-RecordWithIdentifier'\u003e\u003c/a\u003e\n```cs\nvar httpClient = factory.CreateClient();\n\nRecording.Start(testName);\n\nvar companies = await httpClient.GetFromJsonAsync\u003cCompany[]\u003e(\"/companies\");\n\nvar entries = Recording.Stop(testName);\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L566-L576' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-RecordWithIdentifier' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nThe results will not be automatically included in verified file so it will have to be verified manually:\n\n\u003c!-- snippet: VerifyRecordedCommandsWithIdentifier --\u003e\n\u003ca id='snippet-VerifyRecordedCommandsWithIdentifier'\u003e\u003c/a\u003e\n```cs\nawait Verify(\n    new\n    {\n        target = companies!.Length,\n        sql = entries\n    });\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L578-L587' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-VerifyRecordedCommandsWithIdentifier' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## ScrubInlineEfDateTimes\n\nIn some scenarios EntityFrmaeowrk does not parameterise DateTimes. For example when querying [temporal tables](https://learn.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables).\n\n`ScrubInlineEfDateTimes()` is a convenience method that calls `.ScrubInlineDateTimes(\"yyyy-MM-ddTHH:mm:ss.fffffffZ\")`.\n\n\n### Static usage\n\n```\nVerifyEntityFramework.ScrubInlineEfDateTimes();\n```\n\n\n### Instance usage\n\n\u003c!-- snippet: ScrubInlineEfDateTimesInstance --\u003e\n\u003ca id='snippet-ScrubInlineEfDateTimesInstance'\u003e\u003c/a\u003e\n```cs\nvar settings = new VerifySettings();\nsettings.ScrubInlineEfDateTimes();\nawait Verify(target, settings);\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L34-L40' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ScrubInlineEfDateTimesInstance' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Fluent usage\n\n\u003c!-- snippet: ScrubInlineEfDateTimesFluent --\u003e\n\u003ca id='snippet-ScrubInlineEfDateTimesFluent'\u003e\u003c/a\u003e\n```cs\nawait Verify(target)\n    .ScrubInlineEfDateTimes();\n```\n\u003csup\u003e\u003ca href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L48-L53' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ScrubInlineEfDateTimesFluent' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Icon\n\n[Database](https://thenounproject.com/term/database/310841/) designed by [Creative Stall](https://thenounproject.com/creativestall/) from [The Noun Project](https://thenounproject.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.entityframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverifytests%2Fverify.entityframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.entityframework/lists"}