Home > Net >  How to conditionally add value converters if database is SQLite
How to conditionally add value converters if database is SQLite

Time:10-15

I have a question that might be dumb but I've only just discovered Data Conversion in EF Core.

So I need to use a value converter only if the database in use is an SQLite database. Is this possible?

Again; sorry if this question is kinda dumb. Thanks!

CodePudding user response:

In SqliteDatabaseFacadeExtensions Class, There is a static method:

public static bool IsSqlite (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade database);

It Returns true if the database provider currently in use is the SQLite provider.

You can use YourDatabase.IsSqlite() to determine if the database you are using is Sqlite.

You can refer to this Docs to learn more.

  • Related