0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EF CoreでCode Firest multipl prymarykey

Posted at

EF 6とかだとアノテーションでこうできたけど

Model.cs
        [Key, Column(Order = 0) ]
        public int AId { get; set; }
        [Key, Column(Order = 1) ]
        public int BId { get; set; }
        [Key, Column(Order = 2) ]
        public int CId { get; set; }

EFCoreはこう

DbContext.cs
            builder.Entity<Model>().HasKey(p => new {p.AId, p.BId, p.CId});

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?