Class DatabaseBuilder
Supports building and configuring the database.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Migrations.Install
Assembly: cs.temp.dll.dll
Syntax
public class DatabaseBuilder
Constructors
DatabaseBuilder(IScopeProvider, IUmbracoDatabaseFactory, IRuntimeState, ILoggerFactory, IKeyValueService, IDbProviderFactoryCreator, IConfigManipulator, IOptionsMonitor<GlobalSettings>, IOptionsMonitor<ConnectionStrings>, IMigrationPlanExecutor, DatabaseSchemaCreatorFactory)
Initializes a new instance of the Database
Declaration
public DatabaseBuilder(IScopeProvider scopeProvider, IUmbracoDatabaseFactory databaseFactory, IRuntimeState runtimeState, ILoggerFactory loggerFactory, IKeyValueService keyValueService, IDbProviderFactoryCreator dbProviderFactoryCreator, IConfigManipulator configManipulator, IOptionsMonitor<GlobalSettings> globalSettings, IOptionsMonitor<ConnectionStrings> connectionStrings, IMigrationPlanExecutor migrationPlanExecutor, DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory)
Parameters
Type | Name | Description |
---|---|---|
IScope |
scopeProvider | |
IUmbraco |
databaseFactory | |
IRuntime |
runtimeState | |
ILogger |
loggerFactory | |
IKey |
keyValueService | |
IDb |
dbProviderFactoryCreator | |
IConfig |
configManipulator | |
IOptions |
globalSettings | |
IOptions |
connectionStrings | |
IMigration |
migrationPlanExecutor | |
Database |
databaseSchemaCreatorFactory |
Fields
EmbeddedDatabaseConnectionString
Declaration
public const string EmbeddedDatabaseConnectionString = "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1"
Field Value
Type | Description |
---|---|
System. |
LocalDbConnectionString
Declaration
public const string LocalDbConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Umbraco.mdf;Integrated Security=True"
Field Value
Type | Description |
---|---|
System. |
Properties
CanConnectToDatabase
Gets a value indicating whether it is possible to connect to the configured database. It does not necessarily mean that Umbraco is installed, nor up-to-date.
Declaration
public bool CanConnectToDatabase { get; }
Property Value
Type | Description |
---|---|
System. |
IsDatabaseConfigured
Gets a value indicating whether the database is configured. It does not necessarily mean that it is possible to connect, nor that Umbraco is installed, nor up-to-date.
Declaration
public bool IsDatabaseConfigured { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
CanConnect(String, String, String, String, String, String, Boolean)
Verifies whether a it is possible to connect to a database.
Declaration
public bool CanConnect(string databaseType, string connectionString, string server, string database, string login, string password, bool integratedAuth)
Parameters
Type | Name | Description |
---|---|---|
System. |
databaseType | |
System. |
connectionString | |
System. |
server | |
System. |
database | |
System. |
login | |
System. |
password | |
System. |
integratedAuth |
Returns
Type | Description |
---|---|
System. |
ConfigureDatabaseConnection(String)
Configures a connection string that has been entered manually.
Declaration
public void ConfigureDatabaseConnection(string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System. |
connectionString | A connection string. |
Remarks
Has to be SQL Server
ConfigureDatabaseConnection(String, String, String, String, String)
Configures a connection string from the installer.
Declaration
public void ConfigureDatabaseConnection(string server, string databaseName, string user, string password, string databaseProvider)
Parameters
Type | Name | Description |
---|---|---|
System. |
server | The name or address of the database server. |
System. |
databaseName | The name of the database. |
System. |
user | The user name. |
System. |
password | The user password. |
System. |
databaseProvider | The name of the provider (Sql, Sql Azure, Sql Ce). |
ConfigureEmbeddedDatabaseConnection()
Configures a connection string for the embedded database.
Declaration
public void ConfigureEmbeddedDatabaseConnection()
ConfigureIntegratedSecurityDatabaseConnection(String, String)
Configures a connection string using Microsoft SQL Server integrated security.
Declaration
public void ConfigureIntegratedSecurityDatabaseConnection(string server, string databaseName)
Parameters
Type | Name | Description |
---|---|---|
System. |
server | The name or address of the database server. |
System. |
databaseName | The name of the database |
ConfigureSqlLocalDbDatabaseConnection()
Declaration
public void ConfigureSqlLocalDbDatabaseConnection()
CreateDatabase()
Declaration
public void CreateDatabase()
CreateSchemaAndData()
Creates the database schema and inserts initial data.
Declaration
public DatabaseBuilder.Result CreateSchemaAndData()
Returns
Type | Description |
---|---|
Database |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.
GetAzureConnectionString(String, String, String, String)
Gets an Azure connection string.
Declaration
public static string GetAzureConnectionString(string server, string databaseName, string user, string password)
Parameters
Type | Name | Description |
---|---|---|
System. |
server | The name or address of the database server. |
System. |
databaseName | The name of the database. |
System. |
user | The user name. |
System. |
password | The user password. |
Returns
Type | Description |
---|---|
System. |
A connection string. |
GetDatabaseConnectionString(String, String, String, String, String, out String)
Gets a connection string from the installer.
Declaration
public static string GetDatabaseConnectionString(string server, string databaseName, string user, string password, string databaseProvider, out string providerName)
Parameters
Type | Name | Description |
---|---|---|
System. |
server | The name or address of the database server. |
System. |
databaseName | The name of the database. |
System. |
user | The user name. |
System. |
password | The user password. |
System. |
databaseProvider | The name of the provider (Sql, Sql Azure, Sql Ce). |
System. |
providerName |
Returns
Type | Description |
---|---|
System. |
A connection string. |
GetIntegratedSecurityDatabaseConnectionString(String, String)
Gets a connection string using Microsoft SQL Server integrated security.
Declaration
public static string GetIntegratedSecurityDatabaseConnectionString(string server, string databaseName)
Parameters
Type | Name | Description |
---|---|---|
System. |
server | The name or address of the database server. |
System. |
databaseName | The name of the database |
Returns
Type | Description |
---|---|
System. |
A connection string. |
HasSomeNonDefaultUser()
Declaration
public bool HasSomeNonDefaultUser()
Returns
Type | Description |
---|---|
System. |
UpgradeSchemaAndData(UmbracoPlan)
Upgrades the database schema and data by running migrations.
Declaration
public DatabaseBuilder.Result UpgradeSchemaAndData(UmbracoPlan plan)
Parameters
Type | Name | Description |
---|---|---|
Umbraco |
plan |
Returns
Type | Description |
---|---|
Database |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.
Runs whichever migrations need to run.
ValidateSchema()
Validates the database schema.
Declaration
public DatabaseSchemaResult ValidateSchema()
Returns
Type | Description |
---|---|
Database |
Remarks
This assumes that the database exists and the connection string is configured and it is possible to connect to the database.