Microsoft.Data.Sqlite: Add LoadExtension() to SqliteConnection #14789
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This also updates EFCore.Sqlite to use the new method.
There is a breaking change in SpatialiteLoader. The methods used to take a DbConnection (I guess 'cause we could) but now take a SqliteConnection.
You no longer need to call SqliteConnection.EnableExtensions() before using SpatialiteLoader since the new LoadExtension method will bypass the connection setting. This greatly improves usability and makes EnableExtensions only apply to the load_extension SQL function. Given this, EnableExtensions should probably have been a connection string keyword.
In fact, SpatialiteLoader isn't really needed anymore since calling UseNetTopologySuite now loads the extension for open external connections. Maybe we should make it internal. (See #14821)
LoadExtension has some unusual behavior when the connection is closed. Any exceptions will be delayed until the connection is opened, and there is no way to remove an extension you tried to load, so you'll have to create a new connection object to get back in a good state.
Resolves #13826
I'll review these changes in a design meeting to make sure we're OK with them all.✔