Skip to content

The Sqlite EFCore integration creates an "invalid" connection string #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mattleibow opened this issue May 16, 2025 · 2 comments
Open

Comments

@mattleibow
Copy link

Describe the bug

When using the integration like this:

var db = builder.AddSqlite("db")
var web = builder.AddProject<Projects.Hybridisms_Server_WebApp>("webapp")
    .WithReference(db);

It creates a connection string:

Data Source=C:\Users\maleib\AppData\Local\Temp\kt0c3e1b.cve.db;Cache=Shared;Mode=ReadWriteCreate;Extensions=[]

Specifically, it adds the Extensions=[] to the end, which does not seem to be a supported keyword:

https://github.com/dotnet/efcore/blob/d0237c7e0c3192b00766d6a163fe2a5def526e03/src/Microsoft.Data.Sqlite.Core/SqliteConnectionStringBuilder.cs#L42-L53

And, when I access the DB, I get this:

[Exception] Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.GetIndex(string keyword) Line 359
	at Microsoft.Data.Sqlite\SqliteConnectionStringBuilder.cs(359)
[Exception] Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.this[string].set(string keyword, object value) Line 200
	at Microsoft.Data.Sqlite\SqliteConnectionStringBuilder.cs(200)
[Exception] System.Data.Common.dll!System.Data.Common.DbConnectionStringBuilder.ConnectionString.set(string value)
[Exception] Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.SqliteConnectionStringBuilder(string connectionString) Line 255
	at Microsoft.Data.Sqlite\SqliteConnectionStringBuilder.cs(255)
[Exception] Microsoft.EntityFrameworkCore.Sqlite.dll!Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Exists()
[Exception] Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.ExistsAsync(System.Threading.CancellationToken cancellationToken)
[Exception] Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreatedAsync(System.Threading.CancellationToken cancellationToken)
[Exception] Hybridisms.Server.WebApp.dll!Program.<Main>$(string[] args) Line 41
	at D:\GitHub\Hybridisms\Hybridisms.Server.WebApp\Program.cs(41)
System.Private.CoreLib.dll!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task, System.Threading.Tasks.ConfigureAwaitOptions options)
[Waiting on Async Operation, double-click or press enter to view Async Call Stacks]
Hybridisms.Server.WebApp.dll!Program.<Main>(string[] args)

Regression

No response

Steps to reproduce

var db = builder.AddSqlite("db")
var web = builder.AddProject<Projects.Hybridisms_Server_WebApp>("webapp")
    .WithReference(db);

Expected behavior

No exception, or rather no extensions.

Screenshots

No response

IDE and version

VS 2022 Preview

IDE version

No response

Nuget packages


Additional context

No response

Help us help you

Yes, but only if others can assist

@aaronpowell
Copy link
Member

It's designed to work with https://www.nuget.org/packages/CommunityToolkit.Aspire.Microsoft.Data.Sqlite or https://www.nuget.org/packages/CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite which will handle the extensions loading part.

If you're not going to use the Aspire client integrations, you'll need to do some of your own parsing of the connection string and remove the keys that are non-standard

@mattleibow
Copy link
Author

I am using those. It is the Microsoft.Data.Sqlite. But, let me create a sample repo and re validate just in case I am dumb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants