2

In my controller I have a JsonResult function called by a Javascript that's called by a button in View. this will save input from textbox to database table. But in it's first line of code (connecting to Oracle), it's alread having an error:

using (var con = new OracleConnection(ConfigurationManager.ConnectionStrings["DBEntities"].ConnectionString))

An exception of type 'System.ArgumentException' occurred in Oracle.DataAccess.dll but was not handled in user code

Additional information: 'metadata' is an invalid connection string attribute

Here's my auto-generated connectionString in web.config:

<add name="DBEntities" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=DBDEV;PASSWORD=db;PERSIST SECURITY INFO=True;USER ID=db&quot;" providerName="System.Data.EntityClient" />

What seems to be the problem? And how do I fix it?

  • Possible duplicate of [Oracle ODP.Net With Entity Framework 6 - Entity framework database compatible provider could not be found](http://stackoverflow.com/questions/27656519/oracle-odp-net-with-entity-framework-6-entity-framework-database-compatible-pr) – Ravi A. Aug 05 '16 at 03:45
  • I believe the link you posted is not the same with mine. They don't even mention there the metadata connectionstring – Harambe Attack Helicopter Aug 05 '16 at 06:10
  • Not exact duplicate but those are the steps you need to follow to connect with Oracle DB in EF code first approach. It talks about how connection string should exactly look like when using Oracle DB with EF. – Ravi A. Aug 05 '16 at 06:14
  • I tried the solution but it didn't fix my problem. Same `System.ArgumentException` error – Harambe Attack Helicopter Aug 05 '16 at 08:28

1 Answers1

1

I had this same issue and resolved it using this post: Keyword Not Supported: Metadata

The trick is because it is Oracle you need to change your string to something like this:

<add name="DBEntities" connectionString="DATA SOURCE=DBDEV;PASSWORD=db;PERSIST SECURITY INFO=True;USER ID=db&quot;" providerName="Oracle.ManagedDataAccess.Client" />

I know this post is super old, but hopefully this helps someone else.

jozolo
  • 357
  • 4
  • 15