LinqConnect Documentation
Devart.Data.Linq Namespace / DataContext Class / CreateDatabase Method / CreateDatabase(Boolean,Boolean) Method
If set to true, SQL execution errors will be ignored.

If set to true, the schema will be created. Applicable only for Oracle, MySQL, and SQLite, for other providers it is ignored. For SQLite this parameter determines the behavior in case when "FailIfMissing=true;" is set in the connection string and the corresponding database file doesn't exist. In this case:

In other cases this parameter is ignored for SQLite too.


In This Topic
    CreateDatabase(Boolean,Boolean) Method
    In This Topic
    Creates and executes script that creates database tables with their constraints, indexes, and foreign keys.
    Syntax
    'Declaration
     
    Public Overloads Function CreateDatabase( _
       ByVal ignoreErrors As Boolean, _
       ByVal createSchema As Boolean _
    ) As Boolean
    public bool CreateDatabase( 
       bool ignoreErrors,
       bool createSchema
    )

    Parameters

    ignoreErrors
    If set to true, SQL execution errors will be ignored.
    createSchema

    If set to true, the schema will be created. Applicable only for Oracle, MySQL, and SQLite, for other providers it is ignored. For SQLite this parameter determines the behavior in case when "FailIfMissing=true;" is set in the connection string and the corresponding database file doesn't exist. In this case:

    • CreateDatabase(false, false) fails with the "Could not find file 'filename'.".
    • CreateDatabase(false, true) creates the database file.

    In other cases this parameter is ignored for SQLite too.

    Return Value

    False, if there were errors during execution; true, otherwise.
    Remarks

    The database or schema is not created, an existing one is filled. The name of the database is derived by using the following algorithm:

    • If a database is identified in the connection string, its name is used.
    • If a DatabaseAttribute attribute is present, its Name property is used as the name of the database.
    • If there is no database tag in the connection string and a strongly typed DataContext is used, a database that has the same name as the DataContext inheriting class is checked.
    • If a weakly typed DataContext is used, an exception is thrown.
    • If the DataContext has been created by using a file name, the database corresponding to that file name is created.
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also