Oracle Table cannot be found via EF Core

Viewed 598

I am just wondering, why i am getting data, but cannot delete it? The error is

ORA-06550: Row 4, Column 9:

PL/SQL: ORA-00942: Table or View not found

var entries = await _db.Set<T>().Where(x => x.OBJECT_ID == objectId).ToListAsync();
                _db.Set<T>().RemoveRange(entries);
                await _db.SaveChangesAsync();

Corresponding class is

[Table("PC_NS_REC_MSG_LIVE", Schema = "ENERGYDATASTORE")]
public class PC_NS_REC_MSG_LIVE : IReceivedMessage
{

}

It worked before, but suddenly this statement cannot be executed anymore.

3 Answers

I was able to resolve this issue. I switched my query (at another method) from

dbContext.Set<T>.ToListAsync();

to

dbContext.T.FromSql("sqlQueryString").ToListAsync();

After that, I was not able to use any other dbContext.Set<T> or execute DbCommands.

The solution for that was to change the above statement to

dbContext.T.FromSql("sqlQueryString").AsNoTracking().ToListAsync();

Now i am able to use everything as before. Hope this might help others as well.

Remember the Oracle catalog is case-sensitive. And if you use delimited mixed-case identifiers when creating tables, you must use delimited mixed-case identifiers when querying them. If you use un-delimited identifiers when creating tables, Oracle converts the identifiers to all upper case, and converts identifiers in queries to upper case to when matching catalog items.

So

CREATE TABLE "Foo" ...

and

CREATE TABLE Foo ...

create two different tables with different names. The first one is named "Foo" and the second one "FOO". And the query

SELECT * FROM foo

will query the second one.

Related