none
Entity Framework 5 code first for existing database (reverse engineer) does not work with Oracle

    Question

  • I work for a company that uses Oracle 11g (11.2.0.2) and I have the Oracle Data Provider for .NET.  I have VS 2012, .NET 4.5, Windows 7 Professional, and downloaded the "power tools" for Entity Framework 5 (and EF 5 itself, of course.)  

    When I select "Entity Framework | Reverse Engineer Code First", the connection to the database is successful but VS2012 does nothing - no classes, models, etc., are created.  The demo video, of course, uses SQL Server, and after connecting to the database, all kinds of code is generated.

    Anyone know if this is supposed to work with anything other than 100% Redmond products?

    Thanks

    Friday, June 28, 2013 4:00 PM

All replies

  • Hi OldProgrammerME,

    Code First might be not supported in ODP.NET 11.2.0.2.

    https://forums.oracle.com/thread/2456604

    In fact, I would suggest to try Oracle ODP.NET forum to see whether it is currently supported for latest versions.

    I found another article about using code first in ODP.NET. You may have a try with it:

    http://dotnetspeak.com/2012/01/oracle-odp-and-entity-framework-code-first-4-2

    Best regards,

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information for your  convenience. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help


    Monday, July 01, 2013 6:44 AM
    Moderator
  • I have moved beyond the original problem but now have another.  The power tools generated the reverse-engineered classes, etc., and I wrote a very simple test program to exercise a very small part of them (The database has hundreds of tables so it took a long time) and now have very strange behavior.  Here is the simple test program:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Entities;
    using Entities.Models;
    namespace EntitiesConsoleTests
    {
        class Program
        {
            private static void Main(string[] args)
            {
                Console.Write("Press <Enter> to begin...");
                Console.ReadLine();
                try
                {
                    using (var db = new Context())
                    {
                        var q = from usr in db.USERS
                                orderby usr.USERNAME
                                select usr;
                        foreach (var u in q)
                        {
                            Console.WriteLine(u.USERNAME);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception: " + ex.Message);
                }
                Console.Write("Press <Enter>");
                Console.ReadLine();
            }
        }
    }

    Now, when I try to run this test code, and even when the project loads in VS2012, I get this dialog:

    Of course, .NET 4.5 is ALREADY installed, so this is a bogus error.

    Tools in use are: VS2012 (C#), Oracle 11g, EF5 and "power tools", on Windows 7 Enterprise.

    Thanks in advance for any clues or suggestions.

    Peter

    Monday, July 08, 2013 4:06 PM
  • This morning I downloaded and installed the very latest updates for the .NET platform and VS2012.  No change, even trying to open the solution prompts for installing .NET 4.5 (which is already there), and of course, the test app will not run.

    Tuesday, July 09, 2013 1:01 PM
  • Could you please expalin how did get around the orignal problem.i.e Genarating Entities and Context using Power tools.
    Wednesday, September 25, 2013 4:11 PM
  • I did two things, and I don't think I ended up using the Power Tools the way they are intended to work...

    First, I downloaded the latest Oracle driver from Devart (http://www.devart.com/dotconnect/oracle/) which includes EF 5 support.

    Second, I essentially "scavanged" code generated by the initial run of the Power Tools (which did the whole database, 379 tables...) from here and there in order to develop code-first, bounded contexts (small subsets of the database), as I still was unable to specify a subset of the database to reverse-engineer in the Power Tools.

    I basically used what was generated from the initial run as a template for doing code-first.  Unfortunately, it was a copy/paste-and-edit fest...  :-)

    Peter

    Wednesday, September 25, 2013 4:22 PM