Oracle and 2 months ago provided support for EF6. 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> <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.121.2.0, Culture=neutral, publickeytoken=89b483f429c47342 "/>--> </configSections> < entityframework> <defaultconnectionfactory type= " Oracle.manageddataaccess.entityframework.oracleconnectionfactory,oracle.manageddataaccess.entityframework, version=6.121.2.0,culture=neutral,publickeytoken=89b483f429c47342 "/> <providers> <provider InvariantN Ame= "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> < Remove invariant= "Oracle.ManagedDataAccess.Client"/> <add name= "odp.net, Managed Driver" invariant= "oracle.ma Nageddataaccess.client "description=" Oracle Data Provider for. NET, Managed Driver "type=" oracle.manageddataacces S.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 = 1521)) (Connect_data = (SERVER = dedicated) (service_name = ORCL) ) c8/>); 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
<section 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
http://www.cnblogs.com/wlflovenet/p/4187455.html Reprint please indicate the source
Entity Framework6 with Oracle (can implement code first)