We are deploying for MS SQL Server localdbintegration testing.
We are building a database project, and the resulting file is dacpaccopied for use in the IntegrationTests project. So far we have:
DatabaseProject.sqlproj
bin/debug/DatabaseProject.dacpac
IntegrationTests.csproj
bin/debug/DatabaseProject.dacpac
We have an assembly in the IntegrationTests project, where a new new database is created, and dacpac- localdb. In TearDown, the database is deleted, so we have a deterministic state for testing.
This is the code that deploys dacpacthat uses DacServices( Microsoft.SqlServer.Dac, System.Data.SqlLocalDb, System.Data.SqlClient):
public void CreateAndInitializeFromDacpac(
ISqlLocalDbInstance localDbInstance,
string databaseName,
string connectionString,
string dacpacPath)
{
using (var cx = localDbInstance.CreateConnection())
{
cx.Open();
using (var command = new SqlCommand(
string.Format("CREATE DATABASE {0}", databaseName), cx))
command.ExecuteNonQuery();
}
var svc = new DacServices(connectionString);
svc.Deploy(
DacPackage.Load(dacpacPath),
databaseName,
true
);
}
Now we have a couple of database projects, and deployment requires 8s . This increases the overall test execution time.
- dacpac?