Bard.Db is built on top of the Docker.Net project which does most of the hard work. Bard.Db expects that Docker is installed without it it's not going to work. The idea behind bard.Db is to make it easy to spin up an instance of a database from code especially when we are running integration tests.
Before you start, you will need to add a reference to Bard.Db.dll in your project. The simplest way to do this is to use either the NuGet package manager, or the dotnet CLI. Using the NuGet package manager console within Visual Studio run the following command: Install-Package Bard.db
Install-Package Bard.db
Or using the .net core CLI from a terminal window:
dotnet add package Bard.db
Create a new instance of Bard.Db.MsSqlDatabase passing in the database name, SA Password, port number, tag version.
var db = new MsSqlDatabase(
databaseName: "BardDB_SQL_2017",
saPassword: "Password1",
portNumber: "1066",
tagName: "2017-latest");
var result = db.StartDatabase();
This may take a little time the first time as Docker needs to download the image in the background.
To stop the database simply call.
db.StopDatabase();
var db = new PostgresDatabase(
databaseName: "PostgreSQL_latest",
postgresUser: "Db_user",
password: "Password1");
var result = db.StartDatabase();