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!

.net entity framework core public beta

user5716448Apr 24 2019 — edited Apr 29 2019

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 D:\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

Comments

use preferred abbreviation - here are two pictures
Attribute_pref_abbreviation.png
engineering_pref_abbrev.png
Philip

Mike Kutz

@philip-stoyanov-oracle
The PK Attribute on the Parent Entity comes from "Create Surrogate key" on the parent Entity (image 1)
The Attribute I want to modify isn't listed on the Child Entity (image 2).
Beyond that, it looks like this trick should work.
MK
Image 1 - PK on Parent is auto-created
image.png
Image 2 - no Attribute to modify.
image.png

is there a rule for that name?
Philip

Mike Kutz

Where to check?
I'm just starting to use SDDM. I don't think I defined any naming rules.
I've modified the Naming Templates (image). But that should be it. maybe a few check boxes for Engineering.
MK
image.png

HansJK

You can also just type the name you want while editing that attribute in the attribute list.
It will get overridden if you should re-run naming conventions. So I paste my chosen name into the comments of that attribute (not RDBMS comments, just tool comments). then at least I can copy paste it back or I make sure to re-run naming conventions opton without foreign key columns applied.

well, if you want the name to not change then you can use "Tools>Object names administration" utility to make that name unchangeable

Philip

HansJK

Thank you @Philip Stoyanov-Oracle. That is cool.
If I may, it would have been nice if a direct "link" to that feature would be that I could on the relevant object/attribute indicate/tick that it must be fixed and not have to go to another screen to achieve this. Also having this "central" place/way of being able to see all things flagged as fixed.
Just my two cents...

1 - 7

Post Details

Added on Apr 24 2019
10 comments
1,442 views