SqlConnection.RegisteredApplication Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Important
This API is not CLS-compliant.
Gets or sets the middleware application identity reported to the server for this connection.
public:
property Microsoft::Data::SqlClient::RegisteredApplication RegisteredApplication { Microsoft::Data::SqlClient::RegisteredApplication get(); void set(Microsoft::Data::SqlClient::RegisteredApplication value); };
[System.CLSCompliant(false)]
public Microsoft.Data.SqlClient.RegisteredApplication RegisteredApplication { get; set; }
[<System.CLSCompliant(false)>]
member this.RegisteredApplication : Microsoft.Data.SqlClient.RegisteredApplication with get, set
Public Property RegisteredApplication As RegisteredApplication
Property Value
A RegisteredApplication value. The default is Unknown.
- Attributes
Exceptions
The connection is opening or open. The identity is reported during login, so it must be set beforehand.
Examples
Set the identity before opening the connection:
using Microsoft.Data.SqlClient;
using SqlConnection connection = new(connectionString)
{
RegisteredApplication = RegisteredApplication.EntityFrameworkCore
};
connection.Open();
Remarks
This API is intended for registered applications that reserve an identifier in RegisteredApplication. An unregistered identifier may be reported by casting a value to that type.
This value is telemetry. It is supplied entirely by the client, which may report any identifier in range, so it is not an authenticated identity and must not be used for authorization or any other security decision.
The identity is sent once, during login, so it must be set before the connection is opened.
When pooling is enabled the value is reported only while establishing a new physical connection, and it is not part of the pool key. A connection served from the pool therefore reports the identity of whichever connection caused that physical connection to be created, and physical connections opened in the background to satisfy Min Pool Size report Unknown. Applications that mix identities over one connection string should treat this telemetry as indicative rather than exact, or disable pooling where an exact attribution is required.