.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

Session.ConnectionString Property

Gets or sets a connection string.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll


public string ConnectionString { get; set; }
Public Property ConnectionString As String

Property Value

Type Description

Data store connection parameters.


If a connection string is a reference to a Data Store Service (URL), Session connects to a Data Store Service client.

Session throws CannotFindAppropriateConnectionProviderException in the following situations:

A connection string does not contain the XpoProvider attribute and XPO cannot infer the provider name from other attributes.

To get a fully qualified connection string, use the GetConnectionString method of a corresponding connection provider.

A connection string references a Data Store Service and a target platform is .NET Standard or .NET Core.

To connect a .NET Standard/.NET Core project to a Data Store Service, create and configure DataStoreClientAsync or CachedDataStoreClient. For additional information, see WCF Client in .NET Core.

Do not assign the ConnectionString property value to another Session, because the property may return an empty string or the ConnectionString property value of the underlying IDbConnection object. The underlying connection string does not contain the XpoProvider attribute. To connect Session to the same database, create a new IDbConnection object (see the code example below).

using DevExpress.Xpo;
using DevExpress.Xpo.DB;

public static Session CloneSession(Session source) {
    Session result = new Session();
    result.AutoCreateOption = AutoCreateOption.DatabaseAndSchema;
    result.Connection = 
    result.Connection.ConnectionString = source.ConnectionString;
    return result;

To avoid a CannotChangePropertyWhenSessionIsConnectedException, do not change the ConnectionString property value when the IsConnected property returns true.

See Also