Fluent SQL

CREATE DATABASE

Data definition starts with database creation, and the simplest way to do that is to just provide a new name.

The Database class has a static Create() method that takes the name of your new database.

var createStatement = Database.Create("ExampleWorks");
CREATE DATABASE [ExampleWorks];

From there, you can chain optional calls to add file specs for the database’s data and log files.

var createStatement = Database.Create("MyDatabase")
    .On(new Filespec("my_file", "/path/to/file.mdf").WithSize(100.Megabytes()))
    .LogOn(new Filespec("my_log", "/path/to/file.ldf"));
CREATE DATABASE [MyDatabase]
ON (NAME = [my_file], FILENAME = N'/path/to/file.mdf', SIZE = 100MB)
LOG ON (NAME = [my_log], FILENAME = N'/path/to/file.ldf');