Link to home
Start Free TrialLog in
Avatar of wpatterson82
wpatterson82

asked on

C# / Entity Framework - Columns without names

Hi guys,

I am developing a piece of software which integrates with my companies billing system. The creators of the software have allowed us to use all of their stored procedures however they are unwilling to change anything or allow us to unlock/edit them.

There is one procedure which outputs three "No column name" columns. It's not a big deal for me because I know what they do, however when I am trying to use Entity Framework it throws a fit. I have imported the stored procedure and it automatically created three columns named "Column1, Column2, Column3" respectively. I was excited when I saw this because I just referenced those column names in my code and thought all was well.

Well .. not so much. Anytime I execute my code I receive the following error:


"ExceptionMessage=The data reader is incompatible with the specified 'Sedona.Service_Tech_Schedule_Result'. A member of the type, 'Column1', does not have a corresponding column in the data reader with the same name."

Open in new window


I have done hours worth of researching on the web and can't seem to find anyone that has had this problem.

Here is a partial result of the procedure when run in SQL Management Studio
User generated image
Here is the file that Visual Studio generated, Note the columns labeled Column1 and Column2
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace PMT.Models
{
    using System;
    
    public partial class Service_Tech_Schedule_Result
    {
        public string Column1 { get; set; }
        public string Column2 { get; set; }
        public Nullable<System.DateTime> Schedule_Time { get; set; }
        public Nullable<System.DateTime> Dispatch_Time { get; set; }
        public Nullable<System.DateTime> Arrival_Time { get; set; }
        public Nullable<System.DateTime> Departure_Time { get; set; }
        public Nullable<int> Estimated_Length { get; set; }
        public string Problem_Code { get; set; }
        public string Business_Name { get; set; }
        public string ge1_Description { get; set; }
        public int Dispatch_Id { get; set; }
        public string Requested_By { get; set; }
        public string Requested_By_Phone { get; set; }
        public string Address_1 { get; set; }
        public string Address_2 { get; set; }
        public string Address_3 { get; set; }
        public string ge2_Short { get; set; }
        public string ge3_Description { get; set; }
        public string ge4_Description { get; set; }
        public string ge5_Description { get; set; }
        public string Service_Company_Code { get; set; }
        public string Map_Code { get; set; }
        public string Cross_Street { get; set; }
        public string Column3 { get; set; }
        public string Resolution_Code { get; set; }
        public string IsGoBack { get; set; }
        public string Completed { get; set; }
        public int Country_Id { get; set; }
        public string Route_Code { get; set; }
    }
}

Open in new window

"ExceptionMessage=The data reader is incompatible with the specified 'Sedona.Service_Tech_Schedule_Result'. A member of the type, 'Column1', does not have a corresponding column in the data reader with the same name."

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wpatterson82
wpatterson82

ASKER

Great idea! Thanks for your help.