Hopeless
Hopeless

Reputation: 4763

Relational-specific methods can only be used when the context is using a relational database provider?

I've encountered this exception when trying to call DbContext.Database.Migrate. Looks like this is not very common on the net (or Google has some trouble searching it?). The only possible cause I could find is due to in-memory database or some kind of provider that is not relational?

But when debugging, I can see that the provider name is Oracle.EntityFrameworkCore, I'm using Oracle.EntityFrameworkCore 2.19.30 (to connect to an Oracle Database). So this is confusing now, I'm not sure what's wrong here.

The code is simple like this:

_dbContext.Database.Migrate();

Upvotes: 2

Views: 4830

Answers (1)

Hopeless
Hopeless

Reputation: 4763

I think the exception thrown is very confusing. I had to look into the source code for RelationalDatabaseFacadeExtensions.GetRelationalService via which I can see somehow the TService is not loaded. That service type may be contained in some dll (the most possible one is Microsoft.EntityFrameworkCore.Relational.dll, if that dll is not loaded correctly, it will throw the described exception.

Actually in my case, that dll is loaded with wrong version (2.2.4.0 is loaded whereas the Microsoft.EntityFrameworkCore version is 2.2.6.0). All this happened while I try to load them dynamically (not tightly referencing them in projects).

Upvotes: 3

Related Questions