3

I am trying to scaffold some classes from an Oracle database for use with a .NET Core Web API. I have installed the following nuget packages:

Oracle.EntityFrameworkCore - v2.18.0-beta3
Oracle.ManagedDataAccess.Core - v2.18.6

I have tried scaffolding with both providers, and I get two different errors.

Scaffold command - Scaffold-DbContext "Data Source=(DESCRIPTION=(ADDRESS_LIST= (ADDRESS=(COMMUNITY=tcpcom.world)(PROTOCOL=tcp)(HOST={Host})(PORT={Port})))(CONNECT_DATA=(SID={SID}))); User ID={UserId};Password={Password}" {Provider} -o Models

  • Oracle.EntityFrameworkCore scaffold error
    ORA-01017: invalid username/password; logon denied
    • I have confirmed my login details to be correct
  • Oracle.ManagedDataAccess scaffold error
    Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly Oracle.ManagedDataAccess. This attribute is required to identify the class which acts as the design-time service provider factory.
    • I have tried implementing the IDesignTimeDbContextFactory<T> interface with no luck

I've tried countless things from google today with no luck. Could this be a problem with the Oracle drivers?

EDIT

I have created a .NET Core console app, installed EF Core and Oracle.EntityFrameworkCore and tried to scaffold but get the same error. Also confirmed connection string is correct by using it to create a DbContext and query a table, returning records.

JB06
  • 1,881
  • 14
  • 28
  • Do your tests only with `Oracle.EntityFrameworkCore` - the other is not a EF Core provider. I would suggest first creating Net Core console app referencing the same packages and test the connection string with something like this inside `Main`: `new DbContext(new DbContextOptionsBuilder().UseOracle(connection_string).Options).Database.OpenConnection();` – Ivan Stoev May 23 '19 at 06:49
  • @IvanStoev I've tried what you suggested and it looks like it's connecting and opening the connection just fine. – JB06 May 23 '19 at 10:25
  • Ok, the next step could be to try the `Scaffold-DbContext` command from console app. Eventually with `-verbose` option. And see how it goes. – Ivan Stoev May 23 '19 at 10:35
  • @IvanStoev Same error as before, `ORA-01017: invalid username/password; logon denied` – JB06 May 23 '19 at 11:28
  • Hmm, I've just tried it with my test Oracle db and it works. Has to be connection string related. Make sure the connection string inside ""..."" is exactly the same as if you are using `.UseOracle(@"...")`, e.g. no double backslashes etc. There is nothing more I can do, good luck. – Ivan Stoev May 23 '19 at 12:46
  • I even confirmed that I can pull records in the console app, using the exact same connection string that I use in the scaffold command, so I don't think it's a connection string issue. Thanks for your help. – JB06 May 23 '19 at 17:37
  • Strange. `Scaffold-DbContext` works for me. This is what I have in my console app: ` all runtime; build; native; contentfiles; analyzers `. VS2017 15.9.12 if that matters, `netcoreapp2.0`. – Ivan Stoev May 23 '19 at 18:19
  • I have the same exact packages, but I'm in VS 2019 16.1.0 and .NET Core 2.2. Created a new project in 2017, .NET Core 2.0, same packages, same error. I'm at a loss here. – JB06 May 23 '19 at 19:21
  • Are you able to connect with a simple console app, not using scaffolding or Entity Framework Core? This may have nothing to do with EF at all. What is the version of your database? How are you trying to connect? (Are you using OS authentication/Windows Authentication)? Are you passing a username and password? – Christian Shay May 25 '19 at 12:30
  • @ChristianShay I can connect in any way other than when I use the scaffold command. Db version 12.1.0.2.0. Yes, passing username and password – JB06 May 29 '19 at 11:25

1 Answers1

3

The issue turned out to be a dollar sign $ in the password. The VS Package Manager console provides a PowerShell interface, and the $ is a reserved symbol in PowerShell, so it needed to be escaped by placing a backtick ` in front of the $.

Answer from Oracle Community forums.

JB06
  • 1,881
  • 14
  • 28