Petapoco using odp.net Managed driver to connect Oracle

Source: Internet
Author: User
Tags postgresql connectionstrings oracle developer

The following content to be derived from, just for the convenience of the query reproduced here:

Http://www.cnblogs.com/yanxiaodi/p/5038387.html

About a few years ago, I did an Oracle project with Petapoco, and it was cumbersome to install Oracle's client in development. After debugging the environment, until the end of the project are afraid to re-install the system. There is another need to read Oracle recently, but the environment is gone ...

Re-configure it, first use NuGet download installed Petapoco, did not expect the latest version changes relatively large, seemingly missing several classes, time emergency no time to toss, so downloaded an old version of 5.0.1. But really do not want to install Oracle client so fat thing, want to use Oracle.DataAccess.dll to direct access.

To add a database string to the app. Config file:

<connectionStrings>

<add name= "Mydbcontext"

Connectionstring= "Data source= (description=

(Address_list= (address= (protocol=tcp) (host=xxx) (port=1521)))

(Connect_data= (SERVICE_NAME=ORCL)));

User Id=scott; password=xxx; "

Providername= "Oracle.DataAccess.Client"/>

</connectionStrings>

Modify the T4 template database.tt in the following places:

connectionStringName = "Mydbcontext"; Uses last connection string in config if not specified

Namespace = "Domain.models";

Reponame = "Mydbcontext";

Save, without a doubt the error:

// -----------------------------------------------------------------------------------------

Failed to load provider ' Oracle.DataAccess.Client '-the requested. Net Framework Data provider could not be found. may not be installed.

// -----------------------------------------------------------------------------------------

The driver is definitely not installed, in the search for solutions, find these two articles:

The. NET Oracle Developer Gospel--odp.net managed officially launched

Oracle:ODP.NET Managed Small Test sledgehammer

The original Oracle has already launched a managed drive, and does not distinguish between 32-bit or 64-bit, which should be more convenient. Downloads on Oracle's website are disgusting. Then follow the instructions to search for odp.net.managed from NuGet:

To modify the provider of the database connection string after installation:

Providername= "Oracle.ManagedDataAccess.Client"

Again error, or the same mistake, can not find Oracle.ManagedDataAccess.Client this driver:

// -----------------------------------------------------------------------------------------

Failed to load provider ' Oracle.ManagedDataAccess.Client '-the requested. Net Framework Data provider could not be found. may not be installed.

// -----------------------------------------------------------------------------------------

It seems that the direct installation of nuget or not ah, still have to honestly under the net, find this page:

Http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-087491.html

A bunch of Ah!!! What's next???

Here's what I'm following:

After decompression, there are several folders and Dll,dll we have installed through NuGet, there is a install_odpm.bat, it seems to be installed. Run directly, brush it out, then run or brush it out.

Then open the cmd first. Run cmd find this bat and run it:

The original is not directly run, but also to add parameters. Run in the third Way, and error:

It appears that you need to enable Administrator rights, run cmd in Administrator mode, and finally succeed.

Open this bat can see is actually copy a few files to the system directory, automatically added Tnsnames.ora these files.

Run the database.tt again, this time to report other errors:

// -----------------------------------------------------------------------------------------

Failed to read database schema-' User ID ' is an invalid connection string property

// -----------------------------------------------------------------------------------------

It seems that the driver has been loaded properly. Then why do you report this mistake?

For a long reason, the original database connection string can not have a newline! Otherwise Petapoco's T4 template will not be enrolled ...

Also, the latest version of Oracle's official website is already 12.1.0.2.4, and the version on NuGet looks like it hasn't been updated yet.


Comments:#1楼2016-06-13 12:20 | Marksion
Have you solved it, please? Support (0) objection (0)Reply Reference#2楼 2016-11-17 12:34 | Leaf.duan
In fact, it is to configure Config dbproviderfactories just fine. General Web project, modify the configuration of the config is good, of course, can modify the Machine.config, this is a global, configured all the other projects are not configured.
The benefit of discovering this configuration is that the project can not rely directly on the various data driver DLLs, such as NHibernate, to support so many databases, but it does not rely on those DLLs, but rather the dbproviderfactory.
Refer to my configuration (Web. config):
12345678 <system.data>    <DbProviderFactories>      <remove invariant="Npgsql"/>      <add name="PostgreSQL Data Provider"invariant="Npgsql"description=".Net Data Provider for PostgreSQL"type="Npgsql.NpgsqlFactory, Npgsql, Version=3.1.8.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"/>      <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.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>    </DbProviderFactories>  </system.data>
Support (0) objection (0)Reply Reference

Petapoco using odp.net Managed driver to connect Oracle

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.