Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't Connect to Oracle DB Using .NET Entity Framework (ORA-01017)

Adrian AlfaroJun 12 2025 — edited Jun 12 2025

Hi everyone,

I'm trying to connect to an Oracle database from a .NET application using the Oracle.EntityFrameworkCore NuGet package, but I keep encountering authentication errors. Interestingly, I can connect successfully using DBeaver with the same credentials.

I've already tried several possible solutions but haven't been able to resolve the issue.

Things I have tested:

  1. Tried different versions of the package.
  2. Checked the connection string and tested various formats (included in my code).
  3. Verified that the correct values are being used when creating the connection.
  4. My username and password do not contain special characters. Only underscores, which should not be problematic.
  5. Checked for any invisible characters being sent with the credentials.
  6. Confirmed that the host is accessible. I do need to use a VPN, but the server is being reached correctly.

I was encountering the problem in my main project, so I created a new simple console project to test it separately, in case there were any incompatibilities with other packages.

Code:

using Oracle.ManagedDataAccess.Client;

var connectionString1 = "User Id={user};Password={password};Data Source={host}:1521/{db}";
var connectionString2 = "User Id={user};Password={password};Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={host})(PORT=1521))(CONNECT_DATA=(SID={db})))";
var connectionString3 = "User Id={user};Password={password};Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={host})(PORT=1521))(CONNECT_DATA=(SERVICE_NAME={db})))";

var builder = new OracleConnectionStringBuilder(connectionString1);

Console.WriteLine($"User ID: {builder.UserID}");
Console.WriteLine(string.Join(",", builder.UserID.Select(c => ((int)c).ToString())));

Console.WriteLine($"Password: {builder.Password}");
Console.WriteLine(string.Join(",", builder.Password.Select(c => ((int)c).ToString())));

Console.WriteLine($"Data Source: {builder.DataSource}");

Console.WriteLine($"Connection String: {builder.ConnectionString}");

try
{
   using var connection = new OracleConnection(connectionString1);
   connection.Open();
   connection.Close();
}
catch (Exception ex)
{
   Console.WriteLine("Connection failed: " + ex.Message);
}

Error:

Connection failed: ORA-01017: invalid username/password; logon denied https://docs.oracle.com/error-help/db/ora-01017/

Environment:

  1. Oracle.EntityFrameworkCore: 9.23.80 (also tested with lower versions, the error persists)
  2. .NET 8.0
  3. IDE: Visual Studio 2022

Any ideas or suggestions would be greatly appreciated. Thanks!

Edit:

The database isn’t mine, but I was able to figure out its version. It appears to be Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64-bit Production, which was released sometime between 2002 and 2007.
This might be a silly question, but does anyone know if there could be compatibility issues because of this?

Comments
Post Details
Added on Jun 12 2025
3 comments
119 views