I've added Oracle.DataAccess as reference to asp.net core project. I've only installed Oracle Data Provider for .Net when installed ODAC. I would like to make a simple example with Dapper on the project.
public class Program
{
const string connectionString = "xxxxx";
public static void Main(string[] args)
{
IDbConnection connection = new OracleConnection(connectionString);
string sql = "SELECT * FROM People WHERE Name='JOHN'";
var r = connection.Query<People>(sql);
}
}
The application wasn't running. I was getting this error below when I tried "dnx run" on the project folder.
System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.
If you get this message, probably, it means Oracle.DataAccess dll doesn't exist in the GAC.
Open Command Line and go to bin folder under the odp.net e.g.
cd C:\oracle\product\12.1.0\client_x86\odp.net\bin\4
Run this command below
OraProvCfg.exe /action:gac /providerpath:C:\oracle\product\12.1.0\client_x86\odp.net\bin\4\Oracle.DataAccess.dll
After doing these steps I was able to run the project successfully.