Using Oracle with Entity Framework
Download full source code.
Just for fun, I thought I would try out Oracle with Entity Framework Core. It’s not something I would recommend, in the short time I played with it I found it had difficulty with .Any()
, produced exceptions that lacked any useful information and I struggled with documentation.
Docker
First, I got Oracle running in a Docker container. It is an extremely large image, around 15GB!
docker run -e "ORACLE_PWD=somePassword" -p 1521:1521 -p 5500:5500 --name oracle_db container-registry.oracle.com/database/express:latest
That will get it running.
The Application
The application is a simple console application that uses Entity Framework to connect to Oracle, create a table, seed it, and perform a select statement. The full source code is in the attached zip file.
I couldn’t get Entity Framework to create the database for me. The EnsureCreated()
method didn’t work, so I used the SYSTEM database instead.
As I mentioned, there seem to be issues with Oracle and Entity Framework Core. As an alternative, you could try raw SQL queries, but then the benefits of using Entity Framework are lessened.
The full source code is available in the attached zip file.
Download full source code.