Using Stored Procedures with the ADO.NET Entity Framework
- Last Updated: April 16, 2026
- 2 minute read
- ADO.NET
- Documentation
Using stored procedures with the ADO.NET Entity Framework requires mapping functions. Calling these stored procedures is complex and requires some coding.
If you have multiple overloaded stored procedures, the Sybase Entity Framework data provider appends an identifier to each stored procedure name so you can distinguish between them in the SSDL. The data provider removes the appended identifier before calling the stored procedure for your application.
Using Pseudo Stored Procedures
The Connection object includes properties and methods that provide reauthentication and enhanced statistics functionality. The methods and properties are standard in the ADO.NET data provider, but are not available at the ADO.NET Entity Framework layer. Instead, you expose the same functionality through "pseudo" stored procedures.
This approach uses the Entity Data Model (EDM) to achieve results that correspond to the ADO.NET results. This in effect provides entities and functions backed by pseudo stored procedures.
The following table lists the mapping of the SybaseConnection properties to the corresponding pseudo stored procedure.
Mapping to Pseudo Stored Procedure
| SybaseConnection Property | Pseudo Stored Procedure |
| StatisticsEnabled | DDTek_Connection_StatisticsEnabled DDTek_Connection_StatisticsDisabled |
| ResetStatistics | DDTek_Connection_ResetStatistics |
| RetrieveStatistics | DDTek_Connection_RetrieveStatistics |
You can create a function mapping in the entity model to invoke the pseudo-stored procedure. Alternatively, applications can use the ObjectContext to create a stored procedure command as shown in the following C# code fragment:
using (MyContext context = new MyContext())
{
EntityConnection entityConnection = (EntityConnection)context.Connection;
// The EntityConnection exposes the underlying store connection
DbConnection storeConnection = entityConnection.StoreConnection;
DbCommand command = storeConnection.CreateCommand();
command.CommandText = "DDTek_Connection_EnableStatistics";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new Parameter("cid", 1));
}
bool openingConnection = command.Connection.State == ConnectionState.Closed;
if (openingConnection) { command.Connection.Open(); }
int result;
try
{
result = command.ExecuteNonQuery();
}
finally
{
if (openingConnection && command.Connection.State == ConnectionState.Open)
{
command.Connection.Close();
}
}
Using Overloaded Stored Procedures
If you have multiple overloaded stored procedures, the Sybase Entity Framework data provider appends an identifier to each stored procedure name so you can distinguish between them in the SSDL. The data provider removes the appended identifier before calling the stored procedure for your application.