12.6.4 Probando con SQLite
Install-Package Microsoft.EntityFrameworkCore.Sqlite public void ConfigureServices(IServiceCollection services)
{
switch (CurrentEnvironment.EnvironmentName)
{
case "Testing":
//Conexión en Memoria
services.AddDbContext<CaducaContext>(opt =>
opt.UseInMemoryDatabase("Caduca")
.ConfigureWarnings(x => x.Ignore
(InMemoryEventId.TransactionIgnoredWarning)));
break;
case "IntegrationTesting":
var connection = new SqliteConnection
("DataSource=:memory:");
connection.Open();
services.AddDbContext<CaducaContext>(opt =>
opt.UseSqlite(connection));
break;
default:
//Conexión MySQL
services.AddDbContext<CaducaContext>(options =>
options.UseMySql(Configuration
.GetConnectionString("DefaultConnection")));
//Conexión SQL Server
//services.AddDbContext<CaducaContext>(options => options.UseSqlServer(Configuration.GetConnectionString("SQLServerConnection")));
//Conexión SQL Server Azure
//services.AddDbContext<CaducaContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AzureSQLConnection")));
break;
}
}Previous12.6.3 Agregar los passwords como variables de ambienteNext12.6.5 Agregando diferentes parámetros con MSTest
Last updated