Closed grassit closed 4 years ago
I forked the project and made a few changes so it works with Sqlite.
You can have a look at this commit: https://github.com/tomfroehle/CleanArchitecture/commit/6b243ac283160a01c9ac5f437314b75b70176340
One thing to mind: The migrations that are in the project don't work for Sqlite because they are SQL Server specific. You would have to add custom Sqlite Migrations. My quick fix was to remove the Migrate call with a EnsureCreated. This leads to the database being created but it will never be updated.
Thanks for your sample solution, @tomfroehle.
Perhaps I should use Sqlite or InMemory as the default? - since both are cross-platform.
Thoughts?
Thanks for your sample solution, @tomfroehle.
Perhaps I should use Sqlite or InMemory as the default? - since both are cross-platform.
Thoughts?
Would be nice if it ran out of the box without any infrastructure. The only thing would be, that you need separate migration steps for Sqlite
Thanks for raising this issue, I migrated to InMemory as the default (in debug mode) and SQL Server for release. Looked at using Sqlite, but preferred InMemory for ease of use.
I try to build and run the default project created from https://github.com/JasonGT/CleanArchitecture in .NET Core 3.1.100 in Ubuntu, though my questions are not specific to Ubuntu. It uses LocalDB and SQL Server, and I try to replace them with other database systems, e.g. SQLite (it can also be InMemory provided by EF, PostgreSQL, MySQL), by making the following changes:
(1) I found the following file containing "LocalDB":
src/WebUI/appsettings.json
, so I replace its LocalDB connection string with"DefaultConnection": "Data Source=Example.db"
in the file.(2) I found the following file containing "sqlserver":
src/Infrastructure/DependencyInjection.cs
, so I replaceoptions.UseSqlServer()
withoptions.UseSqlite()
in the file.(3) I then add
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
anddotnet add package Microsoft.EntityFrameworkCore.Design
tosrc/WebUI/WebUI.csproj
. There seems to be some version mismatching problem between the dependency packages. I figure that I either need to downgrade the EF Sqlite package version from 3.1.1 to 3.1.0, or upgrade the other packages' versions from 3.1.0 to 3.1.1 except build error telling thatMicrosoft.VisualStudio.Web.CodeGeneration.Design
should remain at 3.1.0(4) After either downgrade SQlite package or upgrade the other packages, I got build error
Some link says they added Sqlite.Design package, but when I run
dotnet add package Entity.Framework.Core.Sqlite.Design
I got error:My questions are:
Thanks.