"Go" Entity Framework6 with Oracle (code first possible)

Source: Internet
Author: User
Tags connectionstrings

Oracle has provided support for EF6 at the end of 2014. Previously only supported to EF5. EF6 has many useful features that are worth upgrading. Here's how to support Oracle

I. Oracle provides some basic knowledge about. NET Support.

1. In the early days, Microsoft did its own System.Data.OracleClient. Now it has become an expired class. Performance and so on are not very good.

2.Oracle official out of the Odp.net Oracle.DataAccess.dll (unmanaged version) also divided into 32/64 bits. It is also troublesome to install a client environment when deploying. Very cumbersome.

3.Oracle official in recent years the new Oracle.ManagedDataAccess.dll this very force no longer distinguish 32/64 bits. And you don't need the client to install anything. Performance has also been improved. Whether it's using ADO or other ORM frameworks

It is recommended to use this version of the DLL. This time our EF6 will also be developed on the basis of this DLL.

The official is this must go official download the latest talent Support EF6 I am not supported from the lower version of NuGet:

Http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html (the version that was downloaded was 4.121.2.0)

Download the Odp.net\managed\common from this directory and take out 2 of the most critical DLLs

Oracle.ManagedDataAccess.dll and Oracle.ManagedDataAccess.EntityFramework.dll

Two. Modify the Webconfig configuration file

Add the following code:

<configsections>    < Sectionname= "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.121.2.0, culture=neutral, publickeytoken=89b483f429c47342 "/> -    </configsections>  <EntityFramework>    <defaultconnectionfactorytype= "Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, oracle.manageddataaccess.entityframework,version=6.121.2.0,culture=neutral,publickeytoken=89b483f429c47342 "  />    <providers>      <providerInvariantName= "Oracle.ManagedDataAccess.Client"type= "Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, version=6.121.2.0, culture=neutral, publickeytoken=89b483f429c47342 "  />         </providers>  </EntityFramework>  <System.Data>    <dbproviderfactories>      <Removeinvariant= "Oracle.ManagedDataAccess.Client" />      <Addname= "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.121.2.0, culture= Neutral, publickeytoken=89b483f429c47342 " />    </dbproviderfactories>  </System.Data>

The connection string is as follows remember to provide the next providerName for Oracle.ManagedDataAccess.Client

 <  connectionstrings  >  <  add  name  = "orastring"   connectionString  = "Data source= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = * * * * *) (PORT = 152 1)) (Connect_data = (SERVER = dedicated) (service_name = ORCL)); User id=*****; password=*****; Persist Security info=true "  ProviderName  = "Oracle.ManagedDataAccess.Client"  />  </ connectionstrings  >  

Here's another note, because there are people and clients that have Oracle installed. This may cause some errors. Here, please check the C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config.

Under the Machine.config (64-bit word path is Framework64, preferably all detected)

Machine.config can be understood as the parent class of webconfig so we need to check if the contents are

<name= "oracle.manageddataaccess.client"  type= " OracleInternal.Common.ODPMSectionHandler, Oracle.manageddataaccess, version=4.121.1.0, Culture=neutral, publickeytoken=89b483f429c47342 "/>

Such content if there is a modified version number versions for the current Oracle.ManagedDataAccess.Client version.

Three. Precautions

1. The prompt table does not exist at the time of access and may not have sufficient permissions. The default schema needs to be set in the Onmodelcreating settings

Modelbuilder.hasdefaultschema ("schema name");

The 2.oracle configuration is configured to be accessed using the Ora method. It is recommended that you do not use the Ora method first, which may be the problem caused by this way of access.

3.oracle access to the problem must go to the official website to see.

Recommended several

Http://docs.oracle.com/cd/E56485_01/win.121/e55744/toc.htm

Http://docs.oracle.com/cd/E56485_01/win.121/e55744/entityMigrate.htm#BABEHEFE

"Go" Entity Framework6 with Oracle (code first possible)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.