Domanda

I'm trying to use Entity Framework with Model-First on an Oracle database. I have installed ODP.NET and the Oracle Visual Studio Tools from the file ODTwithODAC1120320_32bit.zip, which is version 11.2.0.3.20.

I made a small test model, set the connection string to the Oracle DB, changed the code generation templates of the model to Generate Oracle via T4 (TPT).xaml and SSDLToOracle.tt. The code generations is working, however the generated SQL is not usable:

CREATE TABLE "dbo"."Entity1Set" (
   "Id" UNIQUEIDENTIFIER NOT NULL,
   "NvarcharProperty" NVARCHAR(MAX) NOT NULL
);

Neither UNIQUEIDENTIFIER nor NVARCHAR are valid Oracle keywords. Furthermore, Oracle handles schemas differently than SQL Server, so the "dbo". stuff won't work.

How do you usually handle that? Changing the SQL after every code generation?

Are there other ways to use EF with Oracle and Model-First?

È stato utile?

Soluzione

Looks like your model was generated from SqlServer and then passed to the SSDLToOracle.tt. The SSDLToOracle.tt file probably does not check if it is really dealing with Oracle specific StoreItemCollection and just uses what it gets which results in generating a hybrid of Oracle specific SQL that is using SqlServer types. You can check what database the model was generated for by opening the edmx file and checking Provider and ProviderManifestToken attributes.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top