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

c# entity-framework-core oracle

Question

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();
1
1
8/9/2019 4:05:24 PM

Accepted Answer

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).

1
8/11/2019 2:29:39 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow