Migrating EF6 to EF Core 6.0 - Properties in partial class

Dominique Largey 1 Reputation point
2022-11-10T10:21:33.603+00:00

Hello,

Properties added in partial classes are recognized with EF6. With EF Core 6.0, there is no error when compiling, but an error occurs when loading data, new properties are not recognized.
As a workaround, we moved the new properties into a class with inheritance. This is more academic but induces a long code review.

public partial class Contacts  
{  
          public bool IsSelect {get; set;}  
          ........................  
}  

Error loading: IsSelect is not recognized

 public class ContactsExtend : Contacts  
    {  
                   public bool IsSelect {get; set;}  
  
    }  

No error

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
715 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dominique Largey 1 Reputation point
    2022-11-11T08:16:42.247+00:00

    Solution :

    using System.ComponentModel.DataAnnotations.Schema;  
      
    public partial class Contacts  
        {  
           [NotMapped]  
           public bool? IsChecked { get; set; }