1

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?

Jonas Sourlier
  • 13,684
  • 16
  • 77
  • 148
  • According to [Oracle's tutorial](http://download.oracle.com/oll/obe/EntityFrameworkOBE/EntityFrameworkOBE.htm) you have to do the following in Model First _" select SSDLtoOracle.tt for the DDL Generation Template. Make sure that Generate Oracle via T4(TPT).xaml is selected in the Database Generation Workflow property to ensure table per type DDL will be generated."_. – Ben Aug 19 '13 at 16:40
  • 1
    From the question it seems you already did the steps suggested by Ben. I'd say this is a problem with the Oracle tooling... – Alex Paven Aug 19 '13 at 16:45
  • 1
    Are you sure you are not SSDLToOracle.tt against a model generated for Sql Server? Can you paste the store model from your edmx file (the part where you have `Provider` and `ProviderManifestToken` attributes) - the .tt probably blindly generates the code for the StoreItemCollection it gets even though the StoreItemCollection was created for a different database. – Pawel Aug 19 '13 at 17:13

1 Answers1

2

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.

Pawel
  • 31,342
  • 4
  • 73
  • 104