How to add the same column to all entities in EF Core?

后端 未结 2 1313
长发绾君心
长发绾君心 2020-11-30 09:21

Imagine that I want to add an IsDeleted colum or some auditing columns to all of my entities. I could create a base class from which all of my entities will inherit and this

2条回答
  •  醉酒成梦
    2020-11-30 10:09

    You can always generate an initial migration for the model and manually rearrange the column order in the Migration.

    Here is the open issue tracking support for explicit column ordering in EF Core: https://github.com/aspnet/EntityFrameworkCore/issues/10059

    Also see this question and answer on using Shadow Properties and Query Filters for soft deletes. EF Core: Soft delete with shadow properties and query filters

提交回复
热议问题