Skip to Main Content

Oracle Developer Tools for Visual Studio

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to add Oracle provider in VS2017 for Entity Framework?

3213893Mar 7 2018 — edited Mar 12 2018

Hello

I want to connect to a database(Oracle 10g) for generating ADO.NET model, Code First From Database. I have installed ODAC for VS but there is still no option for connecting Oracle DB at the Entity Data Model Wizard:

At Server Explorer there is a Oracle provider

I've also tried to install the following 4 Nuget packages but still no Oracle provider at Entity Data Model Wizard:

More info: https://stackoverflow.com/questions/45950351/how-to-add-oracle-provider-in-vs2017-for-entity-framework

I follow this guide:

https://stackoverflow.com/questions/46061839/how-add-oracle-as-provider-for-entity-data-model-wizard

https://csharp.today/entity-framework-6-database-first-with-oracle/

And install this:

Oracle Developer Tools for Visual Studio 2017 MSI Installer

64-bit Oracle Data Access Components (ODAC) for Windows  (64-bit ODAC 12.2c Release 1 (12.2.0.1.0) for Windows x64)

Thanks

Comments

Alex Keh-Oracle

Did you install ODAC with ODT (i.e. zip file) or did you install ODT for Visual Studio (i.e. exe file)? The former includes unmanaged ODP.NET; the latter does not. If it's the latter, that would be the reason you run into this issue.

You can download the zip file with unmanaged ODP.NET (Oracle.DataAccess) here: ODAC Downloads - Oracle Universal Installer

3687299

Hello,

I installed ODAC for Visual Studio 2017, is the correct (as it worked for sometime as mentioned in my initial post).

Oracle Developer Tools for Visual Studio 2017 MSI Installer

3687299

Any other thoughts on remedying this issue?

Alex Keh-Oracle

Let's step back. Are you trying to use the managed or unmanaged ODP.NET driver now? Your error indicates you are using unmanaged ODP.NET driver (Oracle.DataAccess.Client). If that is not your intention, then you need to modify your EF app to use managed ODP.NET (Oracle.ManagedDataAccess.Client) instead.

Error 175: The ADO.NET provider with invariant name 'Oracle.DataAccess.Client' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details Model1.edmx 8

3687299

Hello,

Thanks for getting back to me,

I'm solely using Entity Framework, no managed data provider for Oracle.

These are my references for the project ..

F1.png

From what I've learned (at least in this project) Oracle.ManagedDataAccess is required for Oracle.ManagedDataAccess.EntityFramework

Thought I'd include the build errors

F2.png

3687299

Okay I believe it's time to give up.

I uninstalled ODAC For Visual Studio 2017, attempted to install the setup in the zip file you mentioned earlier and on my Windows 10 box it will not run. Seems prudent to simply go back to the Oracle managed data provider.

Never had any issues with SQL-Server using Entity Framework in small to extremely large enterprise solutions.

Alex Keh-Oracle

With respect to EF functionality, managed ODP.NET will provide the same functionality as unmanaged ODP.NET. Since managed ODP.NET is easier to configure and setup, being 100% managed without any any unmanaged assembly dependencies, most customers go with managed in the EF use case.

3687299

Hi Alex,

For the record, I went and rewrote my Entity Framework code using the managed data provider e.g.

public bool UpdateOcsRecord(OcsMessage pRecord, bool pShowCommandText = false)

{

bool success = false;

var updateStatement = @"  
    UPDATE OCS\_MESSAGES SET  
        OCS\_MESSAGE\_TXT =    :MessageText,  
        OCS\_LANG\_CODE =      :LanguageCode,  
        OCS\_FORM\_FIELD\_NAME  :FormFieldName,  
        OCS\_FORM\_FIELD\_ORDER :FormFieldOrder  
    WHERE ID = :Identifier";

using (OracleConnection cn = new OracleConnection() { ConnectionString = ConnectionString })

{

    using (OracleCommand cmd = new OracleCommand() { Connection = cn })

    {

        try

        {

            cmd.BindByName = true;

            cmd.CommandText = updateStatement;

            cmd.Parameters.Add(":MessageText", pRecord.MessageText);

            cmd.Parameters\[":MessageText"\].Size = 2000;

            cmd.Parameters.Add(":LanguageCode", pRecord.LanguageCode);

            cmd.Parameters.Add(":FormFieldName", pRecord.FormFieldName);

            cmd.Parameters.Add(":FormFieldOrder", pRecord.FormFieldOrder);

            cmd.Parameters.Add(":Identifier", pRecord.id);

            if (pShowCommandText)

            {

                Console.WriteLine(cmd.ActualCommandText(":"));

            }

            cn.Open();

            cmd.ExecuteNonQuery();

            success = true;

        }

        catch (OracleException oex)

        {

            mHasException = true;

            mLastException = oex;

        }

        catch (Exception ex)

        {

            mHasException = true;

            mLastException = ex;

        }

    }

}

return success;

}

My last shot at Entity Framework got me a bit farther by removing all existing "data connections" in Visual Studio 2017 "Server Explorer". After this I could then change which I could last month then mysteriously did not show up then did after removal of the data connections for Oracle.

F1.png

On the next page for setting up a model I received the following error message. (the settings are the same as used for using the code indicated above and did work last month).

F2.png

In closing the agency I work (Oregon department of employment) for, 99 percent of data storage is in Oracle using Cold Fusion. I was hired last month and have the power to teach C# and the goal was to use Oracle Entity Framework to write services to interact with Cold Fusion, Oracle and a mainframe.

3687299

So I guess at this point there is no clear direction/advise to proceed?

Alex Keh-Oracle

Moving this thread to the ODT forum as the question is specifically about the tools now,

Sorry for the delay in getting back to you.

There is a problem whereby updates to Visual Studio 2017 break the Oracle Developer Tools installation. I want to make sure that is not happening here.

Can you please:

1) Close all instances of Visual Studio.

2) Deinstall ODT and wait to make sure you get a final screen saying the deinstall is done (some versions have a period of time with no window)

3) Reinstall the latest ODT for VS 2017.

Then try your scenario again and let me know.

Thanks!

user5553812

Yes, I cannot use EF Database first w/ ODT 12.2.0.1.1 and VS 2017 15.8.3 (latest as of this writing).  The update from database wizard just flashes the dialog where you are supposed to indicate EF 6 and goes away, with nothing added to the solution.  Did full uninstall/reinstall of ODT.  Guess I'm outta luck and need to skip EF w/ Oracle.  Unless and until Oracle, you decide to make your bits work w/ VS 2017 again

2d73e348-7680-4b2d-bf53-59944f4f4cd9

Sorry to use this work .... but this is so very pathetic, i was about to confirm my client that the architecture of my new project is freeze but this this same thing happened , my VS 2017 got Updated and Database Wizard just flashes and goes off

John Greenstreet

I am having that exact problem with VS 2017 and have uninstalled/reinstalled various ODT versions without success. This is after using Oracle Managed Driver and EF 6 since it came out. But all of a sudden it stopped working and nobody else here's been able to get it to work either.

kakiyama-Oracle

Hi All,

For those having this issue...

1) What is the DB version that you're using?

2) Does the issue go away if you configure TNS_ADMIN in the app.config/web.config that points to the location that has your data source alias defined within a tnsnames.ora file?

Assuming ODP.NET 12.2.01.0 is being used, a sample app.config may look as follows with TNS_ADMIN set.  Please change the directory location of your tnsnames.ora and the version # of the Oracle.ManagedDataAccess.dll that you're using in the <configSections> as appropriate.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <configSections>

    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

  </configSections>

    <oracle.manageddataaccess.client>

      <version number="*">

        <dataSources>

          <settings>

            <setting name="TNS_ADMIN" value="C:\app\client\user\product\12.2.0\client_1\Network\Admin" />

       </settings>

     </version>

  </oracle.manageddataaccess.client> 

</configuration>

Anderson Perim

I have Oracle 11g R2 version in database server. I have the last update of visual studio and the latest version of ManagedDriver. Today i tried to use by TNS option and Entity Data Model Wizard crash after choose connection.

Alex Keh-Oracle

For the users that observe the EDM wizard disappear/crash/go away around the time they are choosing a DB connection to use, I have encountered the same issue before. To fix the issue, verify the first Server Explorer (SE) connection (i.e. the one at the top) works. Just try to open it and make sure it can connect. If it can't connect, fix/replace/delete it so that the first SE connection works.

Once done, try using the EDM wizard again. It should not disappear this time if it's the same issue I've encountered before.

Another possible reason is the scenario @"kakiyama-Oracle" points out in his post. Check if your TNS_ADMIN is set to point to where the data source alias is expected to be.

3810010

I'm having this exact issue too. Steps so far:

1. uninstalled ODT

2. installed newest version of ODT from oracle.  Installed Version 12.2.1200 using all wizard defaults.

3. run VS2017 and open Server Explorer, added an Oracle Connection, applied Filters so the relevant tables are visible

4. create new solution and empty project

5. use Nuget to install Oracle.ManagedDataAccess.EntityFramework version 18.3.0.  This also installed two dependencies, Oracle.ManagedDataAccess version 18.3.0 and EntityFramework version 6.0.0.  (note: had to close VS2017 and reopen project for EF 6.0.0 to be visible in the NuGet package manager).

6. <rclick prj>Add New Item, select ADO.NET Entity Data Model, click Add button.  This runs the Entity Data Model Wizard

7 . select "EF Designer from database" and click Next

8.  select the correct connection, select "Yes, include the sensitive data in the connection string", and click Next

9.  a dialog briefly pops up before disappearing.  On it has one radio button with EF 6.x.x selected.

I can't get the Wizard to go any further.  There are no error messages and no code is added to my project.

What am I doing wrong?

P.S. I even updated the EntityFramework to the latest stable release 6.2.0 and that doesn't work either.

1021767

Hi,

I've exactly the same problem here. I remember that i had one or two years ago a similar problem with a WPF wizard insight Visual Studio 2013. I've reported the problem to Microsoft and they have contacted me with a procedure in order to reproduce the problem and then catch + dump all the exceptions that happened insight the Visual Studio process memory. Finally they could fix the bug.

For our problem now, I've opened a second instance of Visual Studio 2017.

In this second instance of VS, configure your exception settings tab (usually in the windows in the bottom of your IDE) and specify that you want all "Common Language Runtime Exception". In the menu "Debug", "Attach to process" (tick "show  processes from all users), you select the process devenv.exe (be sure to select the right process with the solution from where you try to create "ADO.NET Entity Data Model" (the column "title" in the process explorer window should help you to identify it).

Then switch back to the VS instance with your EF solution, and try to create your entity data model (EF Designer from database). In the window "Choose your Data Connection", fill up the fields and click the button Finish (a window appears quickly and disappears).

You should be able to see now in the output window of the second instance of VS (The one where you are debugging the process) all uncaught exceptions that were raised.

Exception thrown: 'System.ArgumentException' in Oracle.ManagedDataAccess.EntityFramework.dll

Exception thrown: 'System.Data.Entity.Core.ProviderIncompatibleException' in EntityFramework.dll

Exception thrown: 'Microsoft.VisualStudio.TemplateWizard.WizardCancelledException' in Microsoft.Data.Entity.Design.dll

Exception thrown: 'System.Runtime.InteropServices.COMException' in Microsoft.VisualStudio.Shell.15.0.dll

We can see 4 exceptions and maybe the second exception give us the reason : ProviderIncompatibleException. I do not know the reason of this exception....

If one of you has an idea?

Cheers,

Fred

1021767

Hi,

Obviously, the new version 18.3 of Managed Data access drivers is not yet compatible yet with the "Entity Model creation Wizard". Maybe a new package for the ODT (Visual Studio 2017 Oracle developer tools) should be released with the new managed version of the drivers?

Anyway, I've downgraded my "managed data access" components (including entity framework) to version 12.1.100 and now everything works correctly (this version is compatible with the version of the developer tools ODTforVS2017_122011.exe).

BR.

Fred.

Answer

Hi all,

We have released a new version of ODT (18.3) that should fix this issue. Please use ODT 18.3 if you are using ODP.NET 18.3 in your project and using the Entity Framework wizard.

https://www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownloadvs2017-3806459.html

Marked as Answer by 3687299 · Sep 27 2020
1 - 21
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 9 2018
Added on Mar 7 2018
2 comments
4,145 views