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!

How to configure DbContext with ODP.NET Core

c0036513-d01d-46af-8a69-d47e16c6c3ceOct 25 2018 — edited Apr 3 2019

It seems that Oracle released the ODP.NET Core version (see https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core/). If this is accurate, please share how to set it up by using the DbContextOptions (or in any other "injectable" way, not by manually instantiating the connection and command objects (as in https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/ODPNET_Core_get_started/index.html).

I am not able to configure the DbContext from the Startup, Configuration method as described in StackOverflow (https://stackoverflow.com/questions/52972234/options-useoracle-not-available-in-ef-core ):

services.AddDbContext<BloggingContext>(options => options.UseOracle(ora_conn)); 

"UseOracle" is not a method that is available.

I have included the following namespaces:

using Oracle.ManagedDataAccess.Client;

using Microsoft.EntityFrameworkCore;

Even when I try dotnet ef dbcontext scaffold (with and without the option -c HiddenContext), it fails with the 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."

dotnet ef dbcontext scaffold "DATA SOURCE=hidden;PASSWORD=hidden;PERSIST SECURITY INFO=True;USER ID=hidden;Connection Timeout=60;min pool size=0;connection lifetime=1800;" Oracle.ManagedDataAccess --output-dir Tables --schema hidden -t table1 -t table2 -t table3 -t table4 -t table 5 -v

What am I missing? Can anybody point me to any suggestions out there?

Please, please, help...

This post has been answered by Mark Williams on Oct 25 2018
Jump to Answer

Comments

A RMI client talks to a RMI server.

Did you write the C++ program to be a RMI server or client? Since writing a C++ program as a RMI server would be a fairly difficult undertaking and one would really understand RMI when done with it, I would guess that your exe is not a RMI server.

What you could do is write a RMI server in java. Then every time your client called a method on your RMI object it would cause the server to run the C++ exe by using Runtime.exec(). The server would collect the result and return it.
843829
Hi,

I have write a RMI server in java and use it to run my C++ exe. Same as you said. But it still can't return anything to me. I have checked the return stream from this process. Nothing inside.

Any idea??

Thx. a lot

Francis
You would have to provide more information before I could possibly have any ideas. Such as what 'nothing inside' means.

I suggest you seperate out the RMI code from the exec code. Get one piece to work and then the other and then combine them back together.

And use lots of System.out.println().
843829
Dear,

I have used the function available( ) to check the stream. But it return 0. So I said it is nothing inside.

And would you mind give me some examples about this. As I am a newbie in JAVA programming.

Thx.

Francis
You used available() to check which stream?

Presumably you mean the output from the Runtime.exec()? How many times did you check it? Did you wait for the process to terminate?

Reduce the code to the exec() code only and then post it.
843829
Dear,

Here is my code to run the Runtime.exec()

Process tmp = Runtime.getRuntime().exec( cmd )
OutputStream a = Runtime.getOutputStream
int ok = a.available();

And I want to ask how to wait process terminate?

Thx. a lot

Francis
Waiting...

int exitResult = tmp.waitFor();
if (exitResult != 0) {* probably not good*/}
843829
have you tried using exitValue() ? it returns 0 if the subprocess termintated normally
843829
have you tried using exitValue() ? it returns 0 if the
subprocess termintated normally
i should add that 0 is the usual return value. your app could return another value for normal termintation
843829
Dear,

It has returned 0. But I still can't get back the value from C program.

Thx. a lot

Francis
If waitFor returned zero then that is the exit value of the application that is being run. If you expect another value I would suggest looking at how the application is run (for instance if it is being run in a script/batch file that has nothing to do with java.) Or that you reexamine why you think it should be returning something besides zero.

1 - 11

Post Details

Added on Oct 25 2018
29 comments
32,401 views