EF Core 3.0 not able to get data from Oracle view

Hirnesh Jain 1 Reputation point
2020-10-05T08:41:48.737+00:00

Hi,

I am not able retrieve data from Oracle View in using ORacle Entity Framework Core and .Net EF core 3.0, but tables are returning data.

The Context.<ViewName>.ToList() is always showing 0 result with no errors.

the Model is generated using Scaffold-DbContext with Oracle DB connection

Code Sample:

Model Context

public virtual DbSet<XxegcXerpSalesmanMasterV> XxegcXerpSalesmanMasterV { get; set; }

modelBuilder.Entity<XxegcXerpSalesmanMasterV>(entity => { entity.HasNoKey(); entity.ToView("XXEGC_XERP_SALESMAN_MASTER_V", "APPS"); entity.Property(e => e.CreationDate) .HasColumnName("CREATION_DATE") .HasColumnType("DATE"); entity.Property(e => e.Division) .HasColumnName("DIVISION") .HasMaxLength(150) .IsUnicode(false); entity.Property(e => e.EndDateActive) .HasColumnName("END_DATE_ACTIVE") .HasColumnType("DATE"); entity.Property(e => e.LastUpdateDate) .HasColumnName("LAST_UPDATE_DATE") .HasColumnType("DATE"); entity.Property(e => e.MainWhCode) .HasColumnName("MAIN_WH_CODE") .HasMaxLength(3) .IsUnicode(false); entity.Property(e => e.MainWhName) .HasColumnName("MAIN_WH_NAME") .HasMaxLength(240) .IsUnicode(false); entity.Property(e => e.OrgId) .HasColumnName("ORG_ID") .HasColumnType("NUMBER"); entity.Property(e => e.ResourceId) .HasColumnName("RESOURCE_ID") .HasColumnType("NUMBER"); entity.Property(e => e.ResourceStatus) .HasColumnName("RESOURCE_STATUS") .HasColumnType("CHAR(1)"); entity.Property(e => e.RouteCode) .HasColumnName("ROUTE_CODE") .HasMaxLength(16) .IsUnicode(false); entity.Property(e => e.RouteType) .HasColumnName("ROUTE_TYPE") .HasMaxLength(150) .IsUnicode(false); entity.Property(e => e.SalesmanName) .HasColumnName("SALESMAN_NAME") .HasMaxLength(1412) .IsUnicode(false); entity.Property(e => e.SalesmanNumber) .HasColumnName("SALESMAN_NUMBER") .HasMaxLength(30) .IsUnicode(false); entity.Property(e => e.SalesrepId) .HasColumnName("SALESREP_ID") .HasColumnType("NUMBER"); entity.Property(e => e.StartDateActive) .HasColumnName("START_DATE_ACTIVE") .HasColumnType("DATE"); entity.Property(e => e.VanSubinv) .HasColumnName("VAN_SUBINV") .HasMaxLength(30) .IsUnicode(false); });

Class Defination

namespace MVC_oracle.Models { public partial class XxegcXerpSalesmanMasterV { public decimal ResourceId { get; set; } public string SalesmanName { get; set; } public string SalesmanNumber { get; set; } public string RouteCode { get; set; } public string RouteType { get; set; } public string VanSubinv { get; set; } public string MainWhCode { get; set; } public decimal? OrgId { get; set; } public string Division { get; set; } public decimal SalesrepId { get; set; } public string ResourceStatus { get; set; } public DateTime? CreationDate { get; set; } public DateTime? LastUpdateDate { get; set; } public DateTime StartDateActive { get; set; } public DateTime? EndDateActive { get; set; } public string MainWhName { get; set; } } }

Controller Class:

private readonly ModelContext _context;
var SalesMans = _context.XxegcXerpSalesmanMasterV.ToList(); // Not getting data here

Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,002 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,571 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Hirnesh Jain 1 Reputation point
    2020-10-05T15:00:04.357+00:00

    It's not running on Azure..
    The code and database are on local server
    I had to choose tags as it's mandatory to post a question and no tags for .net,efCore available.

    I would be thankful to you for Kindly redirect to the right forum.

    0 comments No comments

  2. Dylan Zhu-MSFT 6,421 Reputation points
    2020-10-06T02:31:24.493+00:00

    Hi HirneshJain-6903,

    Thanks for taking time to report this problem with us. I found a similar issue, maybe it could help you.

    And since your issue is more related to database development. We suggest you could redirect to stack overflow with entity-framework tag, where you will get better support about it.

    Best Regards,
    Dylan


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.