I'm getting the following error while trying to connect to an Oracle database from a new ASP.NET MVC 4 application: "ORA-12154: TNS:could not resolve the connect identifier specified". I'm using the Oracle.ManagedDataAccess DLL (version 4.121.1.0) to try to connect to an Oracle 10g database. Here's the thing - I have an integration test assembly that is successfully connecting to the database using this minimal App.config:
<connectionStrings>
<add name="OracleConnection" connectionString="DATA SOURCE=TNS_NAME;PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>
However, if I try to run my web app with all the crazy Web.config settings, I'm getting the error "ORA-12154: TNS:could not resolve the connect identifier specified". What am I doing wrong? Why is my config for the integration test assembly so simple and the Web.config so complex? Here's the pertinent sections of my Web.config (taken from Deploying and Configuring ODP.NET to work without installation with Entity Framework):
custom configSection:
<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
the corresponding config section:
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
custom system.data node:
<system.data>
<DbProviderFactories>
Remove in case this is already defined in machine.config
<remove invariant="Oracle.DataAccess.Client" />
<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.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
EntityFramework node:
<entityFramework>
<defaultConnectionFactory type="Victoria.Data.OracleConnectionFactory, EntityFramework" />
</entityFramework>
Update 1: After reading through http://docs.oracle.com/cd/E16655_01/win.121/e17732/featConfig.htm#ODPNT8161, I tried modifying my Web.config oracle.manageddataaccess.client to the following and it works. However, it doesn't seem right to have the connectionString node referencing the TNS name AND this extra reference to the same TNS Names file.
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SIEBMATS" descriptor="(DESCRIPTION=(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.yyy.zzz)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = siebmats)))" />
</dataSources>
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
One thing you can try is having the connection string like so:
connectionString="Data Source=//SERVER:PORT/INSTANCE_NAME;USER=XXX;PASSWORD=XXX".
Useful references here:
http://www.connectionstrings.com/oracle/
http://docs.oracle.com/cd/E51173_01/win.122/e17732/featConnecting.htm#ODPNT169
This has also helped me while having problems with EF:
Deploying and Configuring ODP.NET to work without installation with Entity Framework
Hope to have helped.
My problem was in incorrect/incomplete Oracle Driver version, had 11.2.0 installed. I add another 12.2.0 version, didn't change anything in web.config and it worked as charm
I suggest to try the solution proposed by #kolbasov in another thread but about the same problem: https://stackoverflow.com/a/20050462/9390179
It worked for me:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\Oracle\product\11.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>
Related
I'm using EF6 ModelFirst and Oracle ODP Managed driver 12c to develop .NET application (One solution containing solely one project)
I run into a mapping problem between Oracle and .NET.
I'm trying to specify custom mapping in web.config like that :
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1" />
<add name="byte" precision="3" />
<add name="int16" precision="4" />
<add name="int32" precision="9" />
<add name="int64" precision="18" />
</edmMapping>
</edmMappings>
<dataSources>
...
</dataSources>
</version>
</oracle.manageddataaccess.client>
After generating the .edmx, number(5) columns are still mapped into "short" .NET Type (Int16)
Obviously, this .NET Type is not suitable for ZIP code like 59000
If I modify the column mapping from Int16 to Int32 Type in the .edmx, I get the 2019 error specifying that I've got bad mapping
Workaround: When I modify the xml version of the edmx, if I delete the precision of the column it works with Int32 but after updating the model from database, the modifications are overwritten.
The edmMappings syntax has changed with EF 6.
You must now use the following syntax:
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmNumberMapping>
<add NETType="bool" MinPrecision="1" MaxPrecision="1" DBType="Number" />
<add NETType="byte" MinPrecision="2" MaxPrecision="3" DBType="Number" />
<add NETType="int16" MinPrecision="4" MaxPrecision="4" DBType="Number" />
<add NETType="int32" MinPrecision="5" MaxPrecision="9" DBType="Number" />
<add NETType="int64" MinPrecision="10" MaxPrecision="18" DBType="Number" />
</edmNumberMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
You now need to specify the DBType on every line rather than as an attribute to the mapping section.
You also use NETType rather than name.
And finally you must define a min and max precision.
Documentation link: Oracle Number Default Data Type Mapping and Customization Under section Entity Framework 6 Mapping and Customization
I'm trying to integrate Quartz in Castle Windsor. I'm using Quartz 2.2.3. and Windsor.QuartzIntegration 0.3.1.
Windsor is version 3.2.1.
But I'm getting the following error.
An exception of type 'Quartz.SchedulerException' occurred in Quartz.dll but was not handled in user code
Additional information: SchedulerPlugin of type '' could not be instantiated.
InnerException:
Cannot instantiate null
Parameter name: type
I have already tried for over a day to solve this issue, but I don't have a clue how to fix this anymore. Does anyone have a solution for this problem?
Quartz config
<quartz>
<add key="quartz.scheduler.instanceName">XmlConfiguredInstance</add>
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount">5</add>
<add key="quartz.threadPool.threadPriority">2</add>
<add key="quartz.jobStore.misfireThreshold">60000</add>
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
<add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml" />
<add key="quartz.plugin.xml.ScanInterval">10</add>
</quartz>
I am trying to open PostgreSQL connection but getting ReflectionTypeLoadException while opening connection.
Please help me out to solve this problem by providing code or let me know how to remove this exception.
Code i am using so far is below:
**/* Connection String
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="superuserDatabase" value="postgres"/>
</appSettings>
<system.data>
<DbProviderFactories>
<clear/>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="Simple.Data.Properties.Settings.DefaultConnectionString"
connectionString="host=localhost;port=5432;database=SimpleData;user id=postgres;password=P#ssw0rdsa;pooling=false"
providerName="Npgsql" />
<add name="Test"
connectionString="host=localhost;port=5432;database=SimpleData;user id=postgres;password=P#ssw0rdsa;pooling=false"
providerName="Npgsql" />
</connectionStrings>
</configuration>**
*/
I am getting following exception when trying to open connection in POSTGRESQL
var namedDb = Database.OpenNamedConnection("Test").Demo.All();
ReflectionTypeLoadException
This ReflectionLoadTypeException is most often caused because the DLLs you're using aren't up to date so the dependency chain fails. Use nuget to update your project with the latest DLLs. v0.16.2.2 of the PostgreSql provider requires
Simple.Data.Core (≥ 0.12.2.2)
Simple.Data.Ado (≥ 0.12.2.2)
Npgsql (≥ 2.0.11)
(via Mark Rendle) Try explicitly installing 0.16.2.2 of Simple.Data.Ado first, then installing the Postgres package.
I'm new in ASP.NET. Everytime I try to run my application, I encounter the error message below. I already installed .Net Framework Data Provider for MySQL several times.
I hope someone can help me on this. Thanks in advance.
Server Error in '/PLDT QuickSearcher' Application.
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
Add MySql.Data.dll as reference to the project
Add this block to web.config:
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data" />
</DbProviderFactories>
</system.data>
Reference the MySql.Data and MySql.Entities Nuget packages. Then add this line to your web config.
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Your connection string should be similar to the following:
<add name="MyDb" connectionString="Server=127.0.0.1;Port=3306;Database=MyDb;Uid=root;Pwd=;" providerName="MySql.Data.MySqlClient" />
I have solved this problem with following configuration
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
</DbProviderFactories>
</system.data>
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</providers>
</entityFramework>
I am using Enterprise library for my data access.
When I am running the application, at the CreateDatabase() statement I am getting this exception:
Microsoft.Practices.ObjectBuilder2.BuildFailedException
was unhandled by user code
Message="The current build operation
(build key Build
Key[Microsoft.Practices.EnterpriseLibrary.Data.Database,
null]) failed:
The value can not be null or an empty string.
(Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy,
index 2)"
Source="Microsoft.Practices.ObjectBuilder2"
Now, I googled a bit and I found that I have to place
<dataConfiguration defaultDatabase="LocalSqlServer"/>
but I don't know where. Is it the right solution?
Also, at the time of installing enterprise library I didn't see any connection string statement? So, I wonder how it will take the connection string from web.config file.
In the connection string section of my web.config file I have:
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=MSTR;Initial Catalog=USERDb;Integrated Security=true;" providerName="System.Data.SqlClient"/>
Yes you need to add the dataConfiguration section to the web.config.
First you need to add dataConfiguration to the list of ConfigurationSections in your web.config:
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>
Then you need to add your connection strings to the web.config (you've already done this):
<connectionStrings>
<add name="LocalSqlServer" connectionString="Data Source=MSTR;Initial Catalog=USERDb;Integrated Security=true;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Then you need to add the actual dataConfiguration section to the web.config:
<dataConfiguration defaultDatabase="LocalSqlServer"/>
You can also use the Enterprise Library Configuration Tool to do this for you as well.