- 3,715,496 Users
- 2,242,776 Discussions
- 7,845,366 Comments
Forum Stats
Discussions
Categories
- 15 Data
- 362.2K Big Data Appliance
- 6 Data Science
- 1.5K Databases
- 461 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.8K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 246 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 124 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 10 Español
- 1.9K Japanese
- 2 Portuguese
.net entity framework core public beta

Hi,
Using tutorial to look to build a .net core crud usinfg oracle
Have followed the steps at https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/?view=aspnetcore-2.2 and wokr so.k with local sql server database.
However, want to use oracle database as source
Have tried putting below in the context.cs and chnaged the usesqlserver to use oracle in the startup.cs
services.AddDbContext<RazorPagesMultipleContext>(options =>
// options.UseSqlServer(Configuration.GetConnectionString("RazorPagesContext")));
options.UseOracle(Configuration.GetConnectionString("RazorPagesContext")));
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseOracle(@User Id = <userid>; Password = <pwd>; Data Source = <server>:1521/<SID>;);
}
but get message below
Severity Code Description Project File Line Suppression State
Error CS0121 The call is ambiguous between the following methods or properties: 'Microsoft.EntityFrameworkCore.OracleDbContextOptionsExtensions.UseOracle(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder, string, System.Action<Oracle.EntityFrameworkCore.Infrastructure.OracleDbContextOptionsBuilder>)' and 'Microsoft.EntityFrameworkCore.OracleDbContextOptionsBuilderExtensions.UseOracle(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder, string, System.Action<Devart.Data.Oracle.Entity.OracleDbContextOptionsBuilder>)' RazorPages \razorpages\RazorPages\RazorPages\Data\RazorPagesContext.cs 35 Active
Looking at
https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-2.2&tabs=visual-studio suggest can put connection string in the appsettings.json file
shows sqlserver example
RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-1234;Trusted_Connection=True;MultipleActiveResultSets=true"
How can we change this to use Oracle and what is causing ambiguity above? Have
using Oracle.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; included in startup.cs and imported the ef core beta 3 for oracle ef core and
looking ideally to get above working with oracle and any other examples of standard guid cru with ef core and oracle.
Thanks
Answers
-
The ambiguity appears that you have the DevArt EF Core provider installed and setup with your app along with Oracle EF Core. Both providers implement UseOracle() and EF Core doesn't know which one you actually want to use.
-
Thanks for reply - removing devart worked in resolving ambiguity and solution builds o.k.
However, get error message below when tried to run it.
System.ArgumentException: 'AddDbContext was called with configuration, but the context type 'RazorPagesMultipleContext' only declares a parameterless constructor. This means that the configuration passed to AddDbContext will never be used. If configuration is passed to AddDbContext, then 'RazorPagesMultipleContext' should declare a constructor that accepts a DbContextOptions<RazorPagesMultipleContext> and must pass it to the base constructor for DbContext.'
services.AddDbContext<RazorPagesMultipleContext>(options =>
// options.UseSqlServer(Configuration.GetConnectionString("RazorPagesMultipleContext")));
options.UseOracle(Configuration.GetConnectionString("RazorPagesMultipleContext")));
How can we call the context successfully or how should we define below in context
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseOracle(@User Id = <userid>; Password = <pwd>; Data Source = <server>:1521/<SID>;);
}
Thanks
-
This SO thread should be useful in helping you resolve this new issue:
-
Thanks.
Now the solution builds successfully.
However, web page doesn't launch anymore.
works with local sqlserver however when try and use oracle it is no longer launching
called from startup.cs - only diff with oracle one is bits in bold
Any thought as to why not working - anything else missing to get this to work with oracle.
services.AddDbContext<RazorPagesMultipleContext>(options =>
// options.UseSqlServer(Configuration.GetConnectionString("RazorPagesMultipleContext")));
options.UseOracle(Configuration.GetConnectionString("RazorPagesMultipleContext")));
context definition below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Oracle.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace RazorPagesMultiple.Models
{
public class RazorPagesMultipleContext : DbContext
{
public RazorPagesMultipleContext (DbContextOptions<RazorPagesMultipleContext> options)
: base(options)
{
}
public DbSet<RazorPagesMultiple.Models.Multiple> Multiple { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseOracle(@User Id = <uname>; Password = <pwd>; Data Source = <server>:1521/<SID>;);
}
}
}
-
Getting message below now despite fact can tnsping <SID> from command prompt on my pc
Anything else need to set up to get it working with oracle
An unhandled exception occurred while processing the request.
NetworkException: ORA-12154: TNS:could not resolve the connect identifier specified
OracleInternal.Network.AddressResolution..ctor(string TNSAlias, string instanceName)
OracleException: ORA-12154: TNS:could not resolve the connect identifier specified
OracleInternal.ConnectionPool.PoolManager<PM, CP, PR>.Get(ConnectionString csWithDiffOrNewPwd, bool bGetForApp, OracleConnection connRefForCriteria, string affinityInstanceName, bool bForceMatch)
-
Already have a TNS_ADMIN environment variable on pc but thinking something else must be needed to get oracle working with ef core.
-
Managed to get further
Needed to use
optionsBuilder.UseOracle(@User Id = <uname>; Password = <pwd>; Data Source = <SID>;);
However get message table or view does not exist.
On database table name is all upper case but ef core generating sql below in mixed case.
believe problem is that ef core is generating sql with quotation marks - how can this be stopped to allow this to work?
at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Database.Command:Error: Failed executing DbCommand (137ms) [Parameters=[], CommandType='Text', CommandTimeout='0']
SELECT "m"."MULT_MULTIPLE_CODE", "m"."MULT_ANMW_MULTIPLE_CODE", "m"."MULT_AUTH_REQUIRED", "m"."MULT_JMW_MULTIPLE_TYPE_CODE", "m"."MULT_LINK_MULTIPLE_CODE", "m"."MULT_NAME", "m"."MULT_PROM_AUTH_REQUIRED", "m"."MULT_SELECTED_MULTIPLE"
FROM "Multiple" "m"
-
Will start a new thread as looks like have got past first set of issues and now just looking to how can avoid ef core generating quoting which is causing table or view does not exist error
-
I've been trying to take advantage of Oracle.EntityFrameworkCore v3.19 provider for .NetCore.
I've followed Oracle's tutorial in terms of testing these features together. With just a couple classes, a dbSet of those classes. And in the main function I try to add a instance of a class to the DbSet, and try to SaveChanges().
I've also created the tables for those couple classes in my Database schema.
But everytime i run it get an Exception (at the db.SaveChanges(); line):
OracleException: ORA-06550: line 13, column 14: PL/SQL: ORA-00942: table or view does not exist ORA-06550: line 13, column 1: PL/SQL: SQL Statement ignored
Please let me know if there's something i can try to move on from this.
-
I would recommend turning on tracing to see what SQL is being executed when the error occurs. That will tell you the name of the table or view EF Core is trying to use.