0

I want to connect to a Oracle database using Entity Framework version 6.1.3. I'm working with Oracle Managed Data Acces package for Nuget in it's version 19.5.0 and Oracle Managed Data Access Entity Framework Nuget package in it's 19.3.0. Also I'm using Visual Studio 2019. I want to create entities from the database tables using ADO .NET option in VS, but when I try to use this option and click in the Code First from database option, it doesn't show me any connection to oracle database. I have my App.config file like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework"
      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      requirePermission="false"/>
    <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v13.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
      <provider invariantName="Oracle.ManagedDataAccess.Client"
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client"/>
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
        type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no"/>
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.19.1"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>
  <connectionStrings>
    <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client"
      connectionString="User Id=user;Password=password;Data Source=oracle"/>
  </connectionStrings>
</configuration>

I don't know if the problem comes from this file or from another part. Also I have tried creating a new Data Connection, but when I select the Oracle Database option, it says that the provider is deprecated and I have to install Oracle Developer Tools for Visual Studio. I also download this and nothing changes. How can I solve this?

5
  • Did you installed Odac Client? Commented Nov 21, 2019 at 19:14
  • @SelimYıldız No, I didn't. I have to? Commented Nov 21, 2019 at 19:15
  • Yes you have to. You can follow tutorials Entity Framework, LINQ and Model-First for the Oracle Database Commented Nov 21, 2019 at 19:18
  • @SelimYıldız But I'm using Visual Studio 2019 version, there is no problem? I have to download this even if I have references OracleManagedDataAccess? Commented Nov 21, 2019 at 19:19
  • @SelimYıldız I have already downloaded and installed ODAC. Still not working. Commented Nov 22, 2019 at 0:51

1 Answer 1

1

The solution I take to solve this is to uninstall VS 2019 and start to use VS 2017. This is because the ODAC drivers are only compatible with VS 2017 and older versions. Once I do this I was given the option to create a database using ODP .NET driver in the section of Server Explorer located in View -> Server Explorer -> Righ Click in Data Connections -> Add Connection

EDIT Now there are the ODAC drivers to work with Visual Studio 2019

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.