Skip to content

[Feature]: Official sample of working with EF Code First DbContext #4835

@jakoss

Description

@jakoss

Problem Statement

My use case:

  • WebApplicationFactory
  • EF Core DbContext
  • Db in TestContainer

The recommended way of setting up schema migrations is to use SetupAsync. But i cannot inject my DbContext to run Database.MigrateAsync at this point, because nothing in the infrastructure is ready yet.

Also i'm not about how to approach isolation in this scenario, GetIsolatedName doesn't really give me anything here since table names are setup by the EF.

Proposed Solution

I would like to have some official example of how to setup the EF-backed application tests. I'm working on something to make it work, but it feels pretty hacky. I'll attach my solution here after it runs. I'm also willing to provide a PR with the final solution whenever i feel like the solution is good and you agree :)

Alternatives Considered

No response

Feature Category

Documentation

How important is this feature to you?

Important - significantly impacts my workflow

Additional Context

No response

Contribution

  • I'm willing to submit a pull request for this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions