Can we have a table with no primary key but a composite unique key on multiple columns in entity framework?

211 Views Asked by At

We have a following table

public class SomeClass
 {
   public string DocumentId { get; set;}
   public int Action { get; set;}
   public int Status { get; set;}
 }

We expect to have the entries as follows (A unique combination of 3 columns is accepted)

DocumentId   Action     Status
1             Add      Scheduled       = OK
1             Add      InProgress      = OK
2             Add      InProgress      = OK
2            Delete    Scheduled       = THIS OK 
1             Add      Scheduled       = GRRRRR! HERE ERROR

Obviously I cannot have DocumentID as primary key as it has duplicate entries. I cannot have all 3 columns as Primary key since we want to update Status column based on the progress.

So is it possible/OK to create the above table with no primary key and a composite unique key on those 3 columns in EF?

0

There are 0 best solutions below