Error to map in Entityframework

Asked

Viewed 56 times

1

Good,

I’m trying to map a database using Entityframework-Reverse-POCO-Code-First-Generator and one of my views has the following mapping:

public VIEW_CODE_NAV_CustomerLedgerEntryMapping(string schema)
{
    ToTable("VIEW_CODE_NAV_CustomerLedgerEntry", schema);
    HasKey(x => new { x.DocumentType, x.DocumentNo_, x.ExternalDocumentNo_, x.RemainingAmount_LCY_stats_, x.Amount_LCY_stats_, x.PostingDate, x.Open, x.CustomerNo_ });

    Property(x => x.DocumentType).HasColumnName(@"Document Type").HasColumnType("int").IsRequired().HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.DocumentNo_).HasColumnName(@"Document No_").HasColumnType("nvarchar").IsRequired().HasMaxLength(20).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.ExternalDocumentNo_).HasColumnName(@"External Document No_").HasColumnType("nvarchar").IsRequired().HasMaxLength(35).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.RemainingAmount_LCY_stats_).HasColumnName(@"Remaining Amount _LCY_ stats_").HasColumnType("numeric").IsRequired().HasPrecision(38,20).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.Amount_LCY_stats_).HasColumnName(@"Amount _LCY_ stats_").HasColumnType("numeric").IsRequired().HasPrecision(38,20).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.PostingDate).HasColumnName(@"Posting Date").HasColumnType("datetime").IsRequired().HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.Open).HasColumnName(@"Open").HasColumnType("tinyint").IsRequired().HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
    Property(x => x.CustomerNo_).HasColumnName(@"Customer No_").HasColumnType("nvarchar").IsRequired().HasMaxLength(20).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
}

However, when I go to test the application, I get this error:

The data reader is incompatible with the specified 'FAMO.BaseItems.Database.urano.CODE.VIEW_CODE_NAV_CustomerLedgerEntry'. 
A member of the type, 'DocumentNo_', does not have a corresponding column in the data reader with the same name.

Can someone give me a suggestion on what to do?

  • Antonio, good afternoon to you! Commenting on the error you obtained, it would be prudent to check whether the data type/name/size of the field in question, > "Documentno_" has in its dataset, it is complaining exactly about it.

  • @Angelosimonato I put the name DocumentNo_ in the view, it works so I know the problem is related to the column name. I wish I didn’t have to change it.

  • @Antóniogarcez, and what is the name of the field Documentno_ in the view?

No answers

Browser other questions tagged

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