Question

I'm using a Entity Framework 6 implementation on my Windows computer and it's working fine. In order to use on a Linux computer I tried to run the project using Mono. When the program tries to access EF6 I receive the following error:

System.InvalidOperationException: The configured column orders for the table 'Table' contains duplicates. Ensure the specified column order values are distinct.
  at System.Data.Entity.ModelConfiguration.Conventions.ColumnOrderingConventionStrict.ValidateColumns (System.Data.Entity.Core.Metadata.Edm.EntityType table, System.String tableName) [0x00000] in <filename unknown>:0
  at System.Data.Entity.ModelConfiguration.Conventions.ColumnOrderingConvention.Apply (System.Data.Entity.Core.Metadata.Edm.EntityType item, System.Data.Entity.Infrastructure.DbModel model) [0x00000] in <filename unknown>:0
Was it helpful?

Solution

I was able to find a solution. Some of my entities were using the attribute Column. In my case I was using [Column(TypeName = "Date")]. When I have removed this attribute, I was able to run the entity framework on my Linux server.

OTHER TIPS

Using the EF Fluent API instead of the [Column] attribute worked for me:

modelBuilder.Entity().Property(t => t.SomeProp).HasColumnType("mytype");

I know the question is quite old, but anyways, I ended up here.

Using EF Code First, I added a column in my model and changed the table class manually.

Check if there is no duplicates. You can fix it by changing the [Column(Order = 1)].

I got this error for Entity Framework 6 Code First for this model:

public class CycleTest
{
    [MaxLength(5)]
    [Key, Column(Order = 0)]
    public string Action { get; set; }

    [Key, Column(Order = 1)]
    public int Cycle { get; set; }

    public DateTime Created { get; set; }

    [ForeignKey("Case"), Column(Order = 0)]
    public string BusinessSystemId { get; set; }

    [ForeignKey("Case"), Column(Order = 1)]
    public int CaseId { get; set; }

    public virtual Case Case { get; set; }
}

Changed the Column values for ForeignKey properties and then everything worked. Like this:

public class CycleTest
{
    [MaxLength(5)]
    [Key, Column(Order = 0)]
    public string Action { get; set; }

    [Key, Column(Order = 1)]
    public int Cycle { get; set; }

    public DateTime Created { get; set; }

    [ForeignKey("Case"), Column(Order = 2)]
    public string BusinessSystemId { get; set; }

    [ForeignKey("Case"), Column(Order = 3)]
    public int CaseId { get; set; }

    public virtual Case Case { get; set; }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top