DbConfiguration.SetDefaultSpatialServices(DbSpatialServices) DbConfiguration.SetDefaultSpatialServices(DbSpatialServices) DbConfiguration.SetDefaultSpatialServices(DbSpatialServices) Method

Definition

Call this method from the constructor of a class derived from DbConfiguration to set the global instance of DbSpatialServices which will be used whenever a spatial provider is required and a provider-specific spatial provider cannot be found. Normally, a provider-specific spatial provider is obtained from the a DbProviderServices implementation which is in turn returned by resolving a service for DbSpatialServices passing the provider invariant name as a key. However, this cannot work for stand-alone instances of DbGeometry and DbGeography since it is impossible to know the spatial provider to use. Therefore, when creating stand-alone instances of DbGeometry and DbGeography the global spatial provider is always used.

protected internal void SetDefaultSpatialServices (System.Data.Entity.Spatial.DbSpatialServices spatialProvider);
member this.SetDefaultSpatialServices : System.Data.Entity.Spatial.DbSpatialServices -> unit
Protected Friend Sub SetDefaultSpatialServices (spatialProvider As DbSpatialServices)

Parameters

spatialProvider
DbSpatialServices DbSpatialServices DbSpatialServices

The spatial provider.

Remarks

This method is provided as a convenient and discoverable way to add configuration to the Entity Framework. Internally it works in the same way as using AddDependencyResolver to add an appropriate resolver for DbSpatialServices. This means that, if desired, the same functionality can be achieved using a custom resolver or a resolver backed by an Inversion-of-Control container.

Applies to