0

I am not sure how the title could be for this question but I am encounter weird problem. I am using EF 6 with Code First Approach on Oracle DB 12c by using provider Oracle.ManagedDataAccess. My entity classes are created by their default name on Db. For example, User => Users, Role => Roles. When I try to query to table on PL/SQL Developer tool like

select * from Users t

there will be error like

ORA-00942: table or view does not exist

even table is filled. It means "there is no table or view". After trying lot of ways, I found that if I query like

select * from "Users" t

I can reach data now. So the questions are "why does it happen?", "what effects this?"

1 Answer 1

1

It is due to Oracle naming rules. SQL is case-insensitive language, so when you write

select * from Users

Oracle understands this as

select * from USERS

But at the same time, Oracle allows you to create tables with unusual names, which have to be inside qoute marks. To query this table you need to write its name as in the create table statement. Here is a script for SQL*Plus:

SQL> create table "My Table with WEIRD Name" (id number);

Table created.

SQL> select * from "My Table with WEIRD Name";

no rows selected

Such names are case-sensitive, and, as I can guess, Entity Framework creates such names. Names USERS and "USERS" are equivalent, names USERS and "Users" - not. That's why your query works as

select * from "Users"

More information is in documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

This is my first project with Oracle. I thought it would be Entity Framework Code First but now I see what's going on. You are right about EF is creating unusual name for Oracle Db. I also realized that Visual Studio Server Explorer queries to Oracle with table name within qoute marks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.