openiddict / openiddict-samples

.NET samples for OpenIddict

Home Page:https://documentation.openiddict.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlite

feededit opened this issue · comments

Confirm you've already contributed to this project or that you sponsor it

  • I confirm I'm a sponsor or a contributor

Version

new

Question

I feel like Velusia is a different version than previous versions.
I tried running Velusia.
I'm using the previous version without any problems, but I'm intrigued by the new Velusia.
Does the new Velusia have to use sqlite or can I choose between sqlite and ms sql?

Does the new Velusia have to use sqlite or can I choose between sqlite and ms sql?

All the samples have been updated to use SQLite instead of SQL Server as it's available on all platforms (Windows, macOS and Linux) and doesn't require using SQL Express or SQL Server, making them easier to run for non-Windows users 😃

Of course, for deployed applications, SQL Server (or MySQL/MariaDB, PostgreSQL) is the recommended option. SQLite is not suitable for OpenIddict-based production applications.

I am interested in sqlite.
I have a few questions.

  1. Is it possible to transfer saved MS SQL database data to sqlite?
  2. Can the account be used as ms sql and openidick as sqlite?

If there is any documentation or help, please provide a link.

I tried modifying it as below, but it doesn't seem to be the correct way.

From
`
services.AddDbContext(options =>
{
options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-velusia-client.sqlite3")}");
options.UseOpenIddict();
});

`

To

`
services.AddDbContext(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
options.UseOpenIddict();
});

`

Please tell me how to modify it to use MS SQL

Is it possible to transfer saved MS SQL database data to sqlite?

Not directly, as the SQL Server and SQLite DB schemas will differ.

Can the account be used as ms sql and openidick as sqlite?

It's possible: for that, you have to create two different DbContext subclasses (one for Identity and one for OpenIddict). That said, I really don't recommend using SQLite for production environments. SQLite is great for read-only scenarios where you have very few write operations, which isn't a great fit for OpenIddict.

I tried modifying it as below, but it doesn't seem to be the correct way.

It's the correct way.

If you need more information about EF Core, don't miss the documentation here: https://learn.microsoft.com/en-us/ef/core/

Thank you for your kind reply.

Did you only use the two packages below to apply sqlite to your new sample?

Microsoft.EntityFrameworkCore.Sqlite
Microsoft.EntityFrameworkCore.Design

Can I just install the two packages below to modify the new sample with ms sql?
Microsoft.EntityFrameworkCore.SqlServer:
Microsoft.EntityFrameworkCore.Design

Or is there any additional code that needs to be modified in order to apply sqlite to the new sample?

Or is there any additional code that needs to be modified in order to apply sqlite to the new sample?

Nope. For reference, here's the PR that replaced SQL Server by SQLite: #232. As you can see, nothing terribly complicated 😃

I have now seen your answer. thank you