EF - A Member of the type, 'X', does not have a corresponding column in the data Reader with the same name

Asked

Viewed 53 times

0

Good,

I am using Entityframework to pass the result of this query:

SELECT a.* FROM [Logística$Sales Invoice Header] AS a INNER JOIN [Logística$Sales Invoice Line] AS b ON a.No_ = b.[Document No_] WHERE 1 = 1 AND b.Type = 2 AND a.[Bill-to Customer No_] = 'IC00029' AND b.No_ = 'XFMR2812B' AND b.[Cross-Reference No_] = '20M39' AND a.[Document Date] >= CONVERT(datetime, '02/01/2018', 103) AND a.[Document Date] <= CONVERT(datetime, '01/02/2018', 103)

for an instance of the Logistics class. This class was created using the Entityframework (Code-first).

However, give me the following mistake:

The data reader is incompatible with the specified 'FAMO.BaseItems.Database.urano.famNAV.Logística_Sales_Invoice_Header'. A member of the type, 'Sell_to_Customer_No_', does not have a corresponding column in the data reader with the same name.

when the column exists in the class declaration:

namespace FAMO.BaseItems.Database.urano.famNAV
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;

[Table("Logística$Sales Invoice Header")]
public partial class Logística_Sales_Invoice_Header
{
    [Column(TypeName = "timestamp")]
    [MaxLength(8)]
    [Timestamp]
    public byte[] timestamp { get; set; }

    [Key]
    [StringLength(20)]
    public string No_ { get; set; }

    [Column("Sell-to Customer No_")]
    [Required]
    [StringLength(20)]
    public string Sell_to_Customer_No_ { get; set; }

What can it be?

  • Did you make the Migration? It seems that it is back-end change that was not done in the bank.

  • I created the class according to the table and did not change anything in the back-end

  • Remove the line: [Column("Sell-to Customer No_")] and test. If you solve, I’ll give you the answer.

  • I can test this, but that means that every time I upgrade the FE model I have to remember to remove this line and I don’t think it should be like this. I think it should work without using any "trick"

  • The "trick" is only to test my chance of response. Rest assured, if you solve I put the full result.

  • Did not solve and the error is the same.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.