question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Outcome from much discussion on this topic…

In EF6 we tried having column order match the order of properties in the class. The issue is that reflection can return a different order on different architectures. Although the order of properties in the model does not theoretically matter… it actually created a lot of very difficult to debug issues on EF6 where the order had a subtle effect on conventions, model diffing, etc. We managed to fix some of them (after many releases) but there are still some issues we have never really fixed. For that reason, metadata is stored in a deterministic (alphabetical) order in metadata in EF7.

In EF6, we also had a column ordering API, but this only impacts the initial create of the table. If you later change the order, migrations does not handle this (it would require a table rebuild). Also, if you add new columns, they are always appended to the table (since anything else also requires a table rebuild).

We could, however, store an ordering hint as an annotation on the model (based on the reflection order). This would only affect the order that migrations writes the columns in a create table call. That way it doesn’t matter if it changes when you run your app on different platforms, since it’s just an annotation that is ignored for the most part. If we wanted to, we could also flow an order that was specified in [Column] annotations into the hint field.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:8
  • Comments:103 (33 by maintainers)

github_iconTop GitHub Comments

20reactions
ajcvickerscommented, Sep 6, 2016

@vseyedan There is no plan to change this in any of the currently scheduled releases. The correct thing to do it you don’t like the column order is to edit the generated migration file and move the order around as desired.

12reactions
ChristineBoersencommented, Aug 9, 2015

There are times you need to write code at the database level and column order can become more important (inserting into a table without full column specs in a trigger for example). On a wide table, it can save time and since columns in sql databases don’t change order once written easily, is usually fairly safe.

In addition, I prefer to look at the model and data in the same column order 99% of the time so I am not hunting for information visually (example comparing query output debugging a query versus framework output). Maybe it’s a little OCD on my part as well as the consistency just “feels right”.

That or worst case obsolete the currently non-implemented .HasColumnOrder attribute so people know it is incomplete at least. 😃

Christine

From: Erik Ejlskov Jensen [mailto:notifications@github.com] Sent: Sunday, August 9, 2015 2:09 PM To: aspnet/EntityFramework EntityFramework@noreply.github.com Cc: Christine Boersen christine@daisytec.com Subject: Re: [EntityFramework] Migrations: Need column order annotation/API. (#2272)

@ChristineBoersen https://github.com/ChristineBoersen Why do you need to manage the colum order?

— Reply to this email directly or view it on GitHub https://github.com/aspnet/EntityFramework/issues/2272#issuecomment-129222648 . https://github.com/notifications/beacon/ANCv3frvA8bNvpsgfDiBF20GHBH12nS9ks5ol47YgaJpZM4Eqf6c.gif

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is column ordering in Bootstrap
Column ordering classes in Bootstrap helps to change the order of our grid system based on different screen sizes eg: desktop, mobile, ...
Read more >
Data Grid - Column ordering
By default, columns are ordered according to the order they are included in the columns array. By default, DataGridPro allows all column reordering...
Read more >
Row- and column-major order
In computing, row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory.
Read more >
Column Ordering/DnD Feature Guide
The Column Order State is an array of string column ids, that come from the ids or accessorKeys that you defined in your...
Read more >
Grid system
Bootstrap's grid system uses a series of containers, rows, and columns to layout and align content. ... Nestable, Yes. Column ordering, Yes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found