Skip to content

Table column order doesn't follow class property order #2269

Closed as not planned

Description

@jdaley

In 7.0.0-beta3 and EF6, migrations create table columns in the same order that the properties appear in the entity classes. In 7.0.0-beta4, migrations no longer respect this ordering.

Column order makes a big difference to the debugging and support experience when using SQL Management Studio for example. If I'm on a support call and do a quick select * from something, the results are presented in an intuitive way without additional effort. I don't have to scroll sideways through 30 columns to pick out the primary information - it's always at the front. StartDate and EndDate are next to each other and easily compared. RequestedBy and ApprovedBy are grouped together and appear in the same order as the business processes that use them.

Developers specify entity class properties in an order that makes sense. Please reflect that in the generated tables.

Activity

  1. anpete commented on May 26, 2015

    @anpete
    Contributor

    @jdaley We can't match the declared syntactic order because we discover properties via reflection, and that order is non-deterministic.

    In EF6 column order could be controlled via the HasColumnOrder fluent API or the ColumnAttribute data annotation. I've created #2272 to track this in EF7.

  2. rowanmiller commented on May 29, 2015

    @rowanmiller
    Contributor

    Just to add to this, when we tried to use reflection order in past releases of EF we ended up with a number of bugs because we would get properties in a different order on different processors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions