-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
SQLite database created in wrong directory in packaged desktop app. #24213
Comments
I suspect this line needs updating for WinUI 3 Desktop apps.
|
Can you suggest when this might make it into a release? |
Thanks! |
@sjb-sjb I get SQLITE_ERROR from |
@ericsink I think the UWP native assets for e_sqlite3.dll should be used in this case, but I'm not sure NuGet can do that... |
@marb2000 Do you know anyone that can help with NuGet-packaging a library to work with the new stack? The package currently looks like this to get a different native library on UWP, but this falls down in the new world of
|
I'm not caught up yet on this current incarnation of this issue. Is the problem that the wrong native DLL is getting deployed? |
@bricelam Have not compiled and run for some time now due to an extensive set of changes in progress, so it is difficult for me to confirm much right now. Broadly I am using WinUI desktop, Net 5, EF Core 5. |
So, I've opened a PR that enables Microsoft.Data.Sqlite to call This still doesn't work when using e_sqlite3.dll since the API returns SQLITE_ERROR. I suspect it's just deploying the wrong (i.e. non-appcontainer) library. I've verified that the fix works correctly with winsqlite3.dll. |
Maybe. Probably. But it's also the case that in non-UWP builds of SQLitePCLRaw, |
Ah, you're right! Using the UWP provider assembly makes it all work. (with my PR changes) <ItemGroup>
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.0.6" ExcludeAssets="All" GeneratePathProperty="True" />
<Reference Include="$(PkgSQLitePCLRaw_provider_e_sqlite3)\lib\uap10.0\SQLitePCLRaw.provider.e_sqlite3.dll" />
</ItemGroup> |
@bricelam So... is there some change I need to make? Seems like the handling of things like |
Yes, something in the provider package needs to change… I’m just not sure what. Maybe multi-target net5.0-windows in addition to uap10.0? I’m not sure how MSIX-packaging, appcontainers, and NuGet all interact to pick the assets. I haven’t seen any official guidance yet, but it was pretty sparse in UWP too. |
Acknowledged. I'll try to figure this out. |
Under UWP it was not possible to create the SQLite database in any other directory. Is it now possible to create the SQLite database in the user's Documents directory when using a packaged app based on the Windows App SDK, WinUI 3, and .NET 6? |
When using SQLite with EfCore under UWP, new SQLite databases are created in ApplicationData.Current.LocalFolder, in other words [user]\AppData\Local\Packages\[package number]\LocalState.
However, when I compiled my program as a packaged desktop app, the SQLite database was then created in [user]\AppData\Local\VirtualStore\Windows\SysWOW64. I am using WinUI 3 preview 4 with .NET 5 and VS 16.9.0 preview 4, and I created my app with the "Blank App, Packaged (WinUI in Desktop)" template that comes with the WinUI 3 preview 3 extension. I am creating my database using EnsureCreatedAsync() and I am using Microsoft.EntityFrameworkCore.Sqlite v5.0.3.
You may recall that #19754 and #19468 were earlier bugs in which EF did not initialize the SQLite directory. The workaround was to insert the following lines prior to using SQLite:
When I applied this workaround to my packaged desktop app, the SQLite database was then created in ApplicationData.Current.LocalFolder.
P.S. See also Eric Sink's entry in the SQLite repo
The text was updated successfully, but these errors were encountered: