Compartment

This property sets the database compartment's Oracle Cloud ID (OCID).

Declaration

// C#
public string Compartment { set; }

Exceptions

An InvalidOperationException will be raised if the application tries to modify an ociTokenAuthenticationConfiguration object by setting this property once a connection has opened using that configuration object.

Remarks

This parameter is applicable to the OCI API key, OCI interactive, OCI instance principal, and OCI delegation token authentication flows only and is optional. This property becomes mandatory if the OciDatabase property is set.

There is no default value for this parameter. If it is not set, ODP.NET requests access to all the databases within the OCI IAM user's tenancy.

Sample Code

OracleConnection conn = new OracleConnection(constr);
conn.TokenAuthentication = OracleTokenAuth.OciInstancePrincipal;
OciTokenAuthentication tokenconfig = new OciTokenAuthentication{
	Compartment = "<COMPARTMENT OCID>",
	Database = "<DATABASE OCID>"
}
conn.UseOciTokenAuthentication(tokenConfig);
conn.Open();
conn.Close();