Upgrading EntLib 4.1 to 5 with Oracle.DataAccess.Client
I am upgrading a project from EntLib 4.1 to EntLib 5. I've skimmed through the Migration Guide, changed all the references and updated all the config files to point to EntLib 5. All worked fine accept Oracle database access. With the config file:
<configuration>
开发者_StackOverflow<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<dataConfiguration defaultDatabase="prod">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data"
name="Oracle.DataAccess.Client" />
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="prod" connectionString="Data Source=dev;User Id=dev;Password=dev;"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
</configuration>
which worked with 4.1 all calls to DatabaseFactory.CreateDatabase()
fails with:
System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.
If I replace Oracle.DataAccess.Client
with the Microsoft System.Data.Oracleclient
it all works again, but is not full of ODP.net lovelyness. Does anyone know how to get this to work with EntLib 5?
Cheers, Mlk
It seams that the Oracle Installer will sometimes forget about the database provider factory which is installed in the machine.config
. To fix this the following needs to be put in either the app.config
or the machine.condig
.
<system.data>
<DbProviderFactories>
<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
I think this working in EntLib4 is that EntLib4 uses the previous version of the Oracle client (10.2.0.1 I think. Oracle numbering is odd).
Use the configuration showed in this link.
or, check out the App.config from the sample found in the end of the post from that same link.
use ODP.NET 11g for framework 4.
精彩评论