質問

I'm trying to create an Entity Framework model based on USER_OBJECTS so that I can query the inventory of packages & procedures. It looks like calls to USER_OBJECTS must be schema-less, but I can't figure out a way to configure entity / dbcontext to generate a statement without a schema.

1) Is there a special schema prefix that USER_OBJECTS can be called under?

2) If not, then how can I get Entity Framework to drop the schema prefix from the generated statements?

I have found that if I don't provide a schema, it defaults to the executing user, and I get the handy ORA-00942: table or view does not exist error.

If I provide a blank string, it defaults to dbo which isn't helpful at all in Oracle.

Empty String for Schema Method

Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
   ... CODE TRUNCATED FOR READABILITY ...
   Dim entityConfig = entityMethodGeneric.Invoke(modelBuilder, Nothing)
   Dim toTableMethod = entityConfig.[GetType]().GetMethod("ToTable", New Type() {GetType(String), GetType(String)})

   toTableMethod.Invoke(entityConfig, New Object() {"USER_OBJECTS", ""})

   MyBase.OnModelCreating(modelBuilder)
End Sub

Yields

SELECT   "Extent1"."OBJECT_ID" AS "OBJECT_ID"
     ,   "Extent1"."OBJECT_TYPE" AS "OBJECT_TYPE"
     ,   "Extent1"."OBJECT_NAME" AS "OBJECT_NAME"
     ,   "Extent1"."STATUS" AS "STATUS"  

FROM "dbo"."USER_OBJECTS" "Extent1"  

WHERE (("Extent1"."OBJECT_NAME" = :p__linq__0) AND ('PACKAGE' = "Extent1"."OBJECT_TYPE"))
役に立ちましたか?

解決

Apparently you can query USER_OBJECTS against the SYS schema, so I just wired up my entity to use that schema for the necessary tables.

SELECT * FROM SYS.USER_OBJECTS
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top