This is a migrated thread and some comments may be shown as answers.

Oracle Error

1 Answer 42 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ajay
Top achievements
Rank 1
Ajay asked on 20 Oct 2015, 02:28 PM

I am getting the error:

ORA-00942: table or view does not exist Telerik.OpenAccess.RT.sql.SQLException: ORA-00942: table or view does not exist ---> Oracle.DataAccess.Client.OracleException: ORA-00942: table or view does not exist

 I have a Fund table which has a one to many relationship with a FundRecord table:

My Fund poco object is like:

    public class Fund
    {

        public Fund()
        {
            FundRecords = new List<FundRecord>();
        }

        public int Id { get; set; }
        public int FundManagerId { get; set; }
        public string Name { get; set; }
        public DateTime CreatedOn { get; set; }
        public string CreatedBy { get; set; }
        public IList<FundRecord> FundRecords { get; set; }

    }

And my Fund Record: 

     public class FundRecord

    {
        public int Id { get; set; }
        public int FundId { get; set; }
        public decimal MaxExposure { get; set; }
        public int Tier { get; set; }
        public int SupplierRisk { get; set; }
        public decimal SupplierFlowExposure { get; set; }
        public decimal MaxSupplierExposure { get; set; }
        public decimal IndividualSupplierExposure { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public bool IsCurrent { get; set; }
        public string CreatedBy { get; set; }
        public Fund Fund { get; set; }

    }

I am mapping using:

 protected override IList<MappingConfiguration> PrepareMapping()
        {
            List<MappingConfiguration> configurations = new List<MappingConfiguration>();

            var fundMapping = new MappingConfiguration<Fund>();
            fundMapping.MapType(fund => new
            {
                Id = fund.Id,
                FundManagerId = fund.FundManagerId,
                Name = fund.Name,
                CreatedOn = fund.CreatedOn,
                CreatedBy = fund.CreatedBy,
            }).ToTable("FUND");
            fundMapping.HasProperty(c => c.Id).IsIdentity();
            
            var fundRecordMapping = new MappingConfiguration<FundRecord>();
            fundRecordMapping.MapType(fundRecord => new
            {
                Id = fundRecord.Id,
                FundId = fundRecord.FundId,
                MaxExposure = fundRecord.MaxExposure,
                Tier = fundRecord.Tier,
                SupplierRisk = fundRecord.SupplierRisk,
                SupplierFlowExposure = fundRecord.SupplierFlowExposure,
                MaxSupplierExposure = fundRecord.MaxSupplierExposure,
                IndividualSupplierExposure = fundRecord.IndividualSupplierExposure,
                StartDate = fundRecord.StartDate,
                EndDate = fundRecord.EndDate,
                IsCurrent = fundRecord.IsCurrent,
                CreatedBy = fundRecord.CreatedBy,
            }).ToTable("FUNDRECORD");
            fundMapping.HasProperty(c => c.Id).IsIdentity();

          fundMapping.HasAssociation(x => x.FundRecords).WithOpposite(y => y.Fund).HasConstraint((x, y) => x.Id == y.FundId);

            configurations.Add(fundMapping);
            configurations.Add(fundRecordMapping);

            return configurations;


        }

The FluentModel is:

 public class FluentModel : OpenAccessContext
    {
        private static readonly string connectionStringName = @"Connection";

        private static readonly BackendConfiguration backend = GetBackendConfiguration();

        private static readonly MetadataSource metadataSource = new FluentModelMetadataSource();

        public FluentModel()
            : base(connectionStringName, backend, metadataSource)
        {
        }

// ERRORS HERE
        public IQueryable<Fund> Funds
        {
            get { return GetAll<Fund>(); }
        }

        public IQueryable<FundRecord> FundRecords
        {
            get { return GetAll<FundRecord>(); }
        }

        protected override void OnDatabaseOpen(BackendConfiguration backendConfiguration, MetadataContainer metadataContainer)
        {
            metadataContainer.DefaultMapping.InheritanceStrategy = InheritanceStrategy.Horizontal;
            metadataContainer.DefaultMapping.UseDelimitedSQL = false;

            base.OnDatabaseOpen(backendConfiguration, metadataContainer);
        }

        public static BackendConfiguration GetBackendConfiguration()
        {
            var backend = new BackendConfiguration();
            backend.Backend = "Oracle";
            backend.ProviderName = "Oracle.ManagedDataAccess.Client";
            backend.ConnectionPool.InitSQL.Add("ALTER SESSION SET CURRENT_SCHEMA=GENESIS_ALLOCATION");

            return backend;
        } 

 

I am not sure why I am getting this issue so any help would be very helpful.

 Many thanks

 

1 Answer, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 21 Oct 2015, 10:15 AM
Hi Ajay,
Thank you for providing your details.
Such errors can occur if you either have no rights to access the respective table or the table is located in a different schema. What you can do to diagnose this is setting the log level for you application to All by overriding the OnDatabaseOpen method of your context as shown in the following snippet.

protected override void OnDatabaseOpen(BackendConfiguration backendConfiguration, MetadataContainer currentMetadataContainer, MetadataContainer aggregatedMetadataContainer)
{
    backendConfiguration.Logging.LogEvents = LoggingLevel.All;
    backendConfiguration.Logging.LogEventsToTrace = true;
    base.OnDatabaseOpen(backendConfiguration, currentMetadataContainer, aggregatedMetadataContainer);
}

This allows you to see what sql statements are generated against your database. Please check that you have the appropriate rights to access the table and check if potential synonyms are missing.

Another thing to investigate is the exception message. Which table is reported to be missing. Is it the one referenced from your configuration?

Hope this helps.
Feel free to ask in case you have any other question.


Regards,
Ralph Waldenmaier
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.

 
Tags
Data Access Free Edition
Asked by
Ajay
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Share this question
or