Skip to content

pwujczyk/ProductivityTools.CreateSQLServerDatabase

Repository files navigation

CreateSQLServerDatabase

Creates database on SQL Server. Used often before DBUp migrations.

Library allow us to create database from code. Database object exposes three methods:

  • Create – it creates database. If database exists throws exception
  • CreateSilent – it creates database, but before creation it checks if database exists. When true do nothing.
  • Exists – checks if database exists

During creation of database connection string cannot contain database name so library removes it from the connection string if provided. From connection string:

"Server=.\\sql2019;Database=PTMeetings;Integrated Security=True"

Library will make and use

"Server=.\\sql2019;Integrated Security=True"

Database object implement IDatabase interface, so you can inject it or use it in tests if required.

Usage example

Database database = new Database(name, "Server=.\\SQL2019;Trusted_Connection=True;");
database.Create();

Create database

About

Create SQL database in .NET projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages