Gets or sets the data context object to create.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
You can manually create the object for data operations by handling the ContextCreating event and setting the property to an object you have created.
You create the object manually if you want to use a non-default constructor or if you want to create an object that is different from the one specified in the ContextTypeName property.
The property does not contain an instance of the type specified in the ContextTypeName property, because that instance is created after the ContextCreating event. The property is used only when you manually create the data context object during the ContextCreating event. When you are updating, inserting, or deleting data, you must set the property to an object that derives from the DataContext class.
The following example shows how to create the data context object by calling a non-default constructor in an event handler for the ContextCreating event. The code assigns the custom object to the property.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.