Reputation: 748
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?
Upvotes: 0
Views: 3888
Reputation: 748
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
Upvotes: 1