DatabaseExtensionsOpenT Method
This extension method is used to open a connection on a data context when constructed.
Namespace: EWSoftware.EntityFrameworkAssembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static T Open<T>(
this T dataContext
)
where T : DbContext
<ExtensionAttribute>
Public Shared Function Open(Of T As DbContext) (
dataContext As T
) As T
public:
[ExtensionAttribute]
generic<typename T>
where T : DbContext
static T Open(
T dataContext
)
[<ExtensionAttribute>]
static member Open :
dataContext : 'T -> 'T when 'T : DbContext
- dataContext T
- The data context on which to open the connection.
- T
- The data context type
TThe passed data context objectIn Visual Basic and C#, you can call this method as an instance method on any object of type
T. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This method can be used in conjunction with the
NoTrackingT(T) extension method
as shown in the example below.
using var dataContext = new MyDbContext().Open();
... Execute commands ...
using var dataContext = new MyDbContext().NoTracking().Open();
... Execute commands ...