How to make composite unique key in ASP.NET Boilerplate?

前端 未结 2 1658
时光取名叫无心
时光取名叫无心 2021-01-23 18:22

I have a table which has the Id as primary key, I want to have a composite unique key on Code and Value column. I\'m trying in this way.



        
2条回答
  •  孤街浪徒
    2021-01-23 18:49

    Adding solution for others.

    Don't modify anything just add the below line

    modelBuilder.Entity(b =>
            {
                b.HasIndex(e => new { e.Code, e.Value}).IsUnique();
            });
    

提交回复
热议问题