Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
How to have integration test project use a different connection string?

I have connection strings set up in an app.config file, with different files for debug and release based on this SO answer. I'm setting up an integration test project which should be using a different initial catalog for the tests. How do I get the project, and only the integration test project, to use a different connection string?

Edit: Trying to add some more detail. In app.config I have the following:

In the connection string, it has the line initial catalog=MyProgramDB. However I'd like unit tests to use initial catalog=MyIntegrationTestingDB instead.

I tried creating a separate configuration for testing I can switch to, but I can't change the testing projects to any configuration except Debug or Release.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You didn't specify any code, so I will give you an example of how to initialize it with SQL Server and EF.

In your project Startup, you will need to inject the connection string.

It might be something like this:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<DbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("<Name1>"));
}

The <Name1> will be the connection string that you want for the integration tests. In another project, you might use <Name2>.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda