1

I am trying to create a class which all my entities will extend in order to ensure that all required columns are there such as CreatedAt, UpdatedAt, Id.

I am trying to get the timestamps after all columns, however using the order inside of the Column attribute this does not seem to be working, but I believe this to be because all my other columns don't have an order on but I think this is a bit laboursome so was trying to do this automatically from the base class.

public class BaseEntity 
{
   public int Id { get; set; }

   [Column("CreatedAt", Order = 9998 )]
   public DateTime CreatedAt { get; set; }

   [Column("UpdatedAt", Order = 9999 )]
   public DateTime UpdatedAt { get; set; }
}

Is there anyway to automatically doing this without having to specify the order on every property?

jps
  • 20,041
  • 15
  • 75
  • 79
lebber
  • 119
  • 7
  • Does this answer your question? [How to add the same column to all entities in EF Core?](https://stackoverflow.com/questions/52020107/how-to-add-the-same-column-to-all-entities-in-ef-core) – Gert Arnold May 31 '22 at 10:53

0 Answers0