1

This entity/Poco was working fine with EF:

[Column(Name="myFieldNameOnDB")]
public string MyPropNameOnClass{ get; set; }

After replacing EF in the entire solution with Linq2DB, it is working where poco class properties are the same as column/field name, but for some classes, there are some properties that are different than a column in name, that was working with specifying a different name in EF with System.ComponentModel.DataAnnotations but I wonder why not working with LinqToDB.Mapping instead of EF and annotation?

I got the below error: System.Data.SqlClient.SqlError: Invalid column name myFieldNameOnDB

Any help?

Update: My class refer to a SQL View

Bashar Abu Shamaa
  • 1,998
  • 2
  • 21
  • 36
  • Do you want to work with `System.ComponentModel.DataAnnotations` or linq2db mapping is also enough? Linq2db has it's own `LinqToDB.Mapping.ColumnAttribute`. – Svyatoslav Danyliv Apr 06 '21 at 13:16
  • Hey @SvyatoslavDanyliv , for the mentioned exception occurs when using ColumnAttribute of LinqToDB, it was working with DataAnnotations with EF, but I no longer use EF, therefore I went with Ling2DB and LinqToDB.Mapping.ColumnAttribute, and that caused the issue – Bashar Abu Shamaa Apr 06 '21 at 14:20
  • Well it needs investigation. It is common technique and it works very well in many cases. Please create issue with small reproducible steps in github. Anyway, if you defined IMetadataReader - it can be a problem. – Svyatoslav Danyliv Apr 07 '21 at 06:01
  • @Svyatoslav Danyliv Is it work with Views? I updated the question – Bashar Abu Shamaa Apr 08 '21 at 07:47
  • For linq2db there is no differences between tables and views. Do you have IMetadaReader defined? How you migrated to linq2db? – Svyatoslav Danyliv Apr 08 '21 at 09:00

0 Answers0