0

This is not a duplicate of this question as this is entity framework core and that is for normal entity frame work. If you read my question you would've noticed that.

The project I am working on is written in .NET Core 2.2/ I currently have a bunch of models for my entity framework core code-first implementation, they all inherit from BaseEntity and is defined as follows:

public abstract class BaseEntity
{
    public DateTime? CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }
}

But whenever I generate a new migration using Add-Migration it puts the CreatedAt and UpdatedAt columns at the beginning of the table. Is there anyway to specify a column order or something that will put the columns at the end of the table instead of the beginning.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Tachyon
  • 2,171
  • 3
  • 22
  • 46
  • [`ColumnAttribute`](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.schema.columnattribute?view=netcore-2.2) isn't in either framework, but it's use by both frameworks for the same purpose... even [the documentation tells you to use it](https://learn.microsoft.com/en-us/ef/core/modeling/relational/columns). – Erik Philips Mar 09 '19 at 19:18
  • 1
    @ErikPhilips- My apologies, I didn't mention that I already tried that and it had absolutely no effect on the column ordering. – Tachyon Mar 09 '19 at 19:19
  • [Looks like there is a bug in the code itself, even though you're still suppose to use the ColumnAttribute](https://github.com/aspnet/EntityFrameworkCore/issues/11314). – Erik Philips Mar 09 '19 at 19:21
  • @ErikPhilips - Seems I'm shit out of luck, thanks though. – Tachyon Mar 09 '19 at 19:22
  • 1
    Still add them though, for future development/developers :) – Erik Philips Mar 09 '19 at 19:25

0 Answers0