Chebaz
Chebaz

Reputation: 23

How to connect to Oracle 11g in MVC3

I am having a problem to connect to oracle 11g and I have worked upon it for almost a day now. I am using C# and coding in an Mvc3 way. I have the following connection string in web.config file

<add name = "VIPSoracleContext"
    connectionString = "Data Source=localhost:1521/XE; User Id=SYS; Password=PSWRD;"
    providerName="System.Data.OracleClient"/>

I even tried the following connection string again

<add name = "VIPSoracleContext"
    connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=’wkkdmtk’)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME’vipstest’)));User Id=’myID’;Password=’PSWRD’;"
    providerName="System.Data.OracleClient"/>

I still have the following error when creating a controller with read/write templates

error: Unable to retrieve metadata for '...Models.person'. A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'System.Data.OracleClient.OracleConnection'. The store provider might not be functioning correctly.

How can I successfuly connect to oracle 11g with code first? Can anyone please help. Thanx in advnce!

Upvotes: 0

Views: 4647

Answers (1)

Chebaz
Chebaz

Reputation: 23

I got it atlast guys!

Followed this tutorial: http://www.youtube.com/watch?v=68tlel4iJdM But be aware of the default constractor of the context class because if you don't controll it, you will get an error. Follow this link to check what to take cure of with the default constractor: Add Controller in MVC4 not working especially the answer by Arnaldo237.

You will need ODP.net so that provider name Oracle.DataAccess.Client can work.

Enjoy your code at Home.... happy....

Upvotes: 1

Related Questions