I am configuring my entities by having an EntityConfiguration
class that implements IEntityTypeConfiguration<MyEntity>
.
For normal application execution I am using SQL Server and for unit testing I am using SQLite.
The issue is that the SQLite provider has limited features, so I would like to conditionally configure my entities so that if it is using SQL Server, it has additional features, such as RowVersion
:
entity.Property(e => e.RowVersion)
.IsRequired(true)
.IsRowVersion()
.IsConcurrencyToken();
How can I tell which db provider is being used?
1条答案
按热度按时间eqfvzcg81#
Comments to the question give good reasoning why NOT to do it in the code - use the same type of the database in your tests.
But if you still want to do it - I could only think of putting this logic both in the db context and entity type configuration. Please see demo below