Base solution for your next web application
Open Closed

Composive Primary Key on ASP.NET Boilerplate #3232


User avatar
0
jcspader created

I'd like to know if using ASP.NET Boilerplate with EF, is it possible:

  1. Use the composive Primary Key in EF. I have seen many samples with only one column in TPrimaryKey in Repository.

  2. The column's name of Primary Key is required call "Id".

I searched online, but I can't find the answer.


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    Hi My answers;

    1. Use the composive Primary Key in EF. I have seen many samples with only one column in TPrimaryKey in Repository.
    • As Entity Framework allows Composite Primary Keys, ABP has also allows it.
    [Column(Order = 1), Key, ForeignKey("MyForeignKey")]
        public int Field1 { get; set; }
        [Column(Order = 2), Key, ForeignKey("MyForeignKey")]
        public string Field2 { get; set; }
    
    1. The column's name of Primary Key is required call "Id".

    Id column is required to use some rich features with IRepository<T>... If you don't want to use ABP's built-in repository features then there's no requirement for Id field.