Database Methods

The Database type exposes the following members.

  Name Description
Public method CompatibleWithModel This method returns true if the context has a model hash and the database contains a model hash and these hashes match. This indicates that the model used to create the database is the same as the current model and so the two can be used together.
Public method Create Creates a new database on the database server for the model defined in the backing context. Note that calling this method before the database initialization strategy has run will disable executing that strategy.
Public method CreateIfNotExists Creates a new database on the database server for the model defined in the backing context, but only if a database with the same name does not already exist on the server.
Public method Delete() Deletes the database on the database server if it exists, otherwise does nothing.
Public method Static member Delete(DbConnection) Deletes the database on the database server if it exists, otherwise does nothing.
Public method Static member Delete(String) Deletes the database on the database server if it exists, otherwise does nothing. The connection to the database is created using the given database name or connection string in the same way as is described in the documentation for the DbContext class.
Public method Equals Returns whether the specified database is equal to the current database. (Overrides Object.Equals(Object).)
Public method ExecuteSqlCommand Executes the given DDL/DML command against the database.
Public method Exists() Checks whether or not the database exists on the server.
Public method Static member Exists(DbConnection) Checks whether or not the database exists on the server.
Public method Static member Exists(String) Checks whether or not the database exists on the server. The connection to the database is created using the given database name or connection string in the same way as is described in the documentation for the DbContext class.
Protected method Finalize (Inherited from Object.)
Public method GetHashCode Returns the hash function for the specified database. (Overrides Object.GetHashCode().)
Public method GetType Gets the type for the current database.
Public method Initialize Runs the registered IDatabaseInitializer<TContext> on this context. If the parameter force is set to true, then the initializer is run regardless of whether or not it has been run before. This can be useful if a database is deleted while an app is running and needs to be reinitialized.
Protected method MemberwiseClone (Inherited from Object.)
Public method Static member SetInitializer<TContext> Gets or sets the database initialization strategy. The database initialization strategy is called when DbContext instance is initialized from a DbCompiledModel.
Public method SqlQuery(Type, String, Object[]) Creates a raw SQL query that will return elements of the given type. The type can be any type that has properties that match the names of the columns returned from the query, or can be a simple primitive type.
Public method SqlQuery<TElement>(String, Object[]) Creates a raw SQL query that will return elements of the given generic type. The type can be any type that has properties that match the names of the columns returned from the query, or can be a simple primitive type.
Public method ToString Returns a string representation of the database. (Overrides Object.ToString().)
Top
Show: