Skip to content

Run Integrations Tests on GitActions with MsSqlContainer - could not connect to SQL #1366

Answered by HofmeisterAn
vmrsilva asked this question in Q&A
Discussion options

You must be logged in to vote

Removing DbContextOptions is not enough. You need to remove additional classes from the configuration. See the following article for more details.

However, I do not recommend this approach. Instead, use the Connection Strings approach (see Set Redis connection string). It is much easier to set up, cleaner, and aligns with what you typically use in production. Essentially, what you need is:

private sealed class CustomWebApplicationFactory : WebApplicationFactory<Program>
{
    protected override void ConfigureWebHost(IWebHostBuilder builder)
    {
        builder.UseSetting("ConnectionStrings:MSSQL", _msSqlContainer.GetConnectionString());
    }
}

Then, retrieve the connection string from …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by vmrsilva
Comment options

You must be logged in to vote
2 replies
@HofmeisterAn
Comment options

@vmrsilva
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants