C
C#13mo ago
VK

how to to register multiple Entity Framework Core database providers

how to to register multiple Entity Framework Core database providers (Microsoft.EntityFrameworkCore.Sqlite and Pomelo.EntityFrameworkCore.MySql) in the same service provider. Error: Services for database providers 'Microsoft.EntityFrameworkCore.Sqlite', 'Pomelo.EntityFrameworkCore.MySql' have been registered in the service provider. Only a single database provider can be registered in a service provider. If possible ensure that entity framework is managing its service provider by removing the call to 'UseInternalServiceProvider' . Otherwise consider conditionally registering the database provider or maintaining one service provider per database provider.
3 Replies
Angius
Angius13mo ago
You will need multiple dbcontexts
VK
VKOP13mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ I have already one DbContext which is consuming MySQL server database provider and I wanted to mock this DbContext using SQLite database provider. Do I need to create a similar DbContext for SQLite?
Pobiega
Pobiega13mo ago
No, you change the provider in your test setup, usually done in a test fixture or similar Google "ef core test provider" and im sure you'll find a guide on how

Did you find this page helpful?