This project has moved. For the latest updates, please go here.
1
Vote

Column mapping is wrong when column attribute is used and first column is not key

description

In this example it mixes up the column names for the two properties
 class Context : DbContext
    {
        public DbSet<Entity> Entities { get; set; }
    }

    class Entity
    {
        [Column(Order = 0)]
        public Guid TenantId { get; set; }

        [Key]
        [Column(Order = 1)]
        public Guid Id { get; set; }
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            var context = new Context();
            var map = context.Db<Entity>();
            Console.WriteLine(string.Join("\r\n",map.Properties.Select(p => p.PropertyName + "->" + p.ColumnName)));
            //Wrong property to column
            Console.ReadLine();
        }
    }

comments