How to connect Mono in Linux to Oracle
Long post about all the steps I did can be found here: How I managed to connect from Mono in Linux to Oracle
If you are using ServiceStack.OrmLite
it is extremely easy in the end:
Attention! This solution might bring problems with it if you need timezone aware TimeStamps and TimeSpans in Oracle. Use it with caution.
After a lot of searching, the simplest solution was to modify ServiceStack.OrmLite.Oracle
to use Oracle's manged driver. For it to work, I had to remove the OracleTimestampConverter
, because Oracle's managed driver doesn't have the GetClientInfo
function in the OracleGlobalization
class. The code changes can be seen on GitHub. I've also published these changes as a package on NuGet.
The beauty of this solution is that you don't need anything extra anymore. You can take for instance my Ubuntu-mono Docker image, configure your driver and ConnectionString in web.config
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<!-- If any should be in the machine.config -->
<add name="Oracle Data Provider for .NET" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<clear />
<add name="OracleContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="DATA SOURCE=<IP_ADDRESS>:1521/XE;PASSWORD=<PASSWORD>;USER ID=<USER_ID>;Connection Timeout=600;Validate Connection=true" />
</connectionStrings>
... and it is WORKING!