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.

Column order not scaffolded as attribute

See original GitHub issue

See this in 7.0 RC1, when using DataAnnotations

        modelBuilder.Entity<Shipper>(entity =>
        {
            entity.Property(e => e.ShipperId).HasColumnOrder(0);
            entity.Property(e => e.CompanyName).HasColumnOrder(1);
            entity.Property(e => e.Phone).HasColumnOrder(2);
        });
public partial class Shipper
{
    [Key]
    [Column("ShipperID")]
    public int ShipperId { get; set; }

    [StringLength(40)]
    public string CompanyName { get; set; } = null!;

    [StringLength(24)]
    public string? Phone { get; set; }

    [InverseProperty("ShipViaNavigation")]
    public virtual ICollection<Order> Orders { get; } = new List<Order>();
}

I was hoping for this:

public partial class Shipper
{
    [Key]
    [Column("ShipperID", Order = 0)]
    public int ShipperId { get; set; }

    [StringLength(40)]
    [Column("CompanyName", Order = 1)]
    public string CompanyName { get; set; } = null!;

    [StringLength(24)]
    [Column("Phone", Order = 2)]
    public string? Phone { get; set; }

    [InverseProperty("ShipViaNavigation")]
    public virtual ICollection<Order> Orders { get; } = new List<Order>();
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
bricelamcommented, Sep 7, 2022

Yeah, we’re not supposed to scaffold that. We just use it to sort the CLR properties. (Which would then be used by Migrations to re-create the columns in the same order.)

2reactions
ajcvickerscommented, Sep 7, 2022

Also surprised with scaffold this. I don’t think we should by default. /cc @bricelam

Read more comments on GitHub >

github_iconTop Results From Across the Web

entity framework - EF7 Scaffolding not creating columns
I fixed the problem. First I had foreign key properties, so my models looked like this: public Order Order {get;set;} public Guid OrderId ......
Read more >
ScaffoldColumnAttribute Class (System.ComponentModel. ...
It hides the ThumbnailPhotoFileName column by applying the scaffold property to the ThumbnailPhotoFileName object and setting it to false . C# Copy. [ ......
Read more >
The Grid will not create columns for scaffolded = false column
Hello Vasile, Basically you can use the [HiddenInput(DisplayValue=false)] attribute to your model property. Or you can mark the column as ...
Read more >
Features Of Entity Framework Core 2.1 - Better Column ...
Yes and No - The first thing to understand is that the logical order of columns in a table has an impact on...
Read more >
Exploring Dynamic Data: Scaffolding attributes for business logic
Scaffolding is a term that describes letting the business logic determine the list of columns and tables displayed in your user interface.
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