efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Microsoft.Data.Sqlite without its own System.Memory on modern .NET

Open DevAM-Tools opened this issue 1 year ago • 3 comments

I use Microsoft.Data.Sqlite in a .NET 9.0 project. However Microsoft.Data.Sqlite is only available as netstandard2.0 lib. With its dependency of to SQLitePCLRaw.core you inherit a dependency to System.Memory. And with System.Memory you inherit a dependency to System.Buffers, System.Numerics.Vectors, System.Runtime.CompilerServices.Unsafe and so on. Each of these libs comes with its own copy.

Image

My understanding is that .NET 9 and already many version before these libs comes bundeled with the runtime. So there is no need for these dependencies anymore. Please correct my if I am wrong.

That's why I want to propose to make Microsoft.Data.Sqlite support net6.0 (and or net8.0) in addition to netstandard2.0.

Note: SQLitePCLRaw.core would have to do the same change to get the actual benefit. But someone has to make the first step.

DevAM-Tools avatar Oct 16 '25 12:10 DevAM-Tools

Microsoft.Data.Sqlite is owned by efcore so transferring the issue there

akoeplinger avatar Oct 16 '25 15:10 akoeplinger

The extra dependency on System.Memory (and the other transitive dependencies) shouldn't have any actual effect on modern .NET, as the types within should simply be type-forwarding to the built-in types.

But I think it does make sense for the package to target net8.0 in addition to netstandard2.0 - we should also allow ourselves to use modern .NET APIs in M.D.Sqlite (with #if etc.).

/cc @cincuranet

roji avatar Oct 16 '25 16:10 roji

Microsoft.Data.Sqlite is just a meta package that references Microsoft.Data.Sqlite.Core and SQLitePCLRaw.bundle_e_sqlite3. The Microsoft.Data.Sqlite.Core itself is using (for 10.0) net8.0 and netstandard2.0 and by itself it is not referencing System.Memory.

The dependencies you're seeing are from SQLitePCLRaw. As @roji said, these are generally not a problem on newer versions of .NET, because the build system will forward those into built-in types.

You can try to propose this in SQLitePCLRaw.

cincuranet avatar Oct 17 '25 07:10 cincuranet