UpdateDBSchema compares a data context meta model with a database and adjusts the db schema to match the data context model.

Namespace:  Huagati.DBMLTools.Runtime
Assembly:  HuagatiDBMLToolsRTE (in HuagatiDBMLToolsRTE.dll) Version: 1.66.3362.23798

Syntax

C#
public static bool UpdateDBSchema(
	this DataContext dc,
	IDbConnection connection,
	bool createIndexesForFKs
)
Visual Basic (Declaration)
<ExtensionAttribute> _
Public Shared Function UpdateDBSchema ( _
	dc As DataContext, _
	connection As IDbConnection, _
	createIndexesForFKs As Boolean _
) As Boolean
Visual C++
[ExtensionAttribute]
public:
static bool UpdateDBSchema(
	DataContext^ dc, 
	IDbConnection^ connection, 
	bool createIndexesForFKs
)

Parameters

dc
Type: System.Data.Linq..::.DataContext
A Linq to SQL data context.
connection
Type: System.Data..::.IDbConnection
A database connection for the database to update.
createIndexesForFKs
Type: System..::.Boolean
Boolean flag controlling whether to create indexes corresponding to foreign key constraints or not,

Return Value

True if successful, false if updating the schema failed

Examples

This example shows how to call UpdateDBSchema for a specific connection and generate indexes for all foreign key constraints.
CopyC#
using Huagati.DBMLTools.Runtime;

public class UpdateDCSample
{
    public void UpdateSchema()
    {
        SomeDataContext dc = new SomeDataContext();

        //attempt to update the database schema
        dc.UpdateDBSchema(dc.Connection, true);
    }
}

See Also