IT:AD:Code First:Entities:Properties

  • MUST: mark Scalar Properties as virtual to enable improved Change Tracking (by going from Snapshot CT to Proxy POCO Change Tracking, which is based on IPOCO/IEntityWithChangeTracker).
  • MUST: mark Collection Navigation Properties as virtual to enable lazy loading.
  • MUST: Navigation Collection properties must implement ICollection<Entities>
  • SHOULD: As we are working with proxies, can use private set for Id, etc:
    • public string Id {get; private set;}
  • CONSIDER: For properties that need to ignored:
  • CONSIDER: For derived calculated properties that need to be saved, use empty sets:
    • public FullName {get {return _first + " " + _last;} set {}}
      * CONSIDER: If you have to turn of Id autogeneration:
    • DataAnnotations: ? (see IT:AD:Code First:DataAnnotations)
    • FluentAPI: within DataContext.OnModelCreating(): modelBuilder.Entity<Dept>().Property(t => t.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); (see IT:AD:Code First:FluentAPI:Properties)
  • /home/skysigal/public_html/data/pages/it/ad/code_first/entities/properties.txt
  • Last modified: 2023/11/04 22:54
  • by 127.0.0.1