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