Example #1
0
        /// <summary>
        ///     Call this method from the constructor of a class derived from <see cref="DbConfiguration" /> to add
        ///     an implementation of <see cref="DbSpatialServices" /> to use for a specific provider.
        /// </summary>
        /// <remarks>
        ///     The given spatial provider type should have a <see cref="DbProviderNameAttribute" /> applied to it.
        ///     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
        ///     <see cref="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.
        /// </remarks>
        /// <param name="spatialProvider"> The spatial provider. </param>
        protected internal void AddDbSpatialServices(DbSpatialServices spatialProvider)
        {
            Check.NotNull(spatialProvider, "spatialProvider");

            _internalConfiguration.CheckNotLocked("AddDbSpatialServices");
            foreach (var providerInvariantNameAttribute in DbProviderNameAttribute.GetFromType(spatialProvider.GetType()))
            {
                RegisterDbSpatialServices(providerInvariantNameAttribute.Name, spatialProvider);
            }
        }