Skip to content

Commit b0be36b

Browse files
author
Marc Sallin
committed
#60: Added sample code.
1 parent cb0ca2a commit b0be36b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

SQLite.CodeFirst.Console/Entity/Player.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ namespace SQLite.CodeFirst.Console.Entity
66
public class Player : Person
77
{
88
[Index] // Automatically named 'IX_TeamPlayer_Number'
9-
[Unique(OnConflictAction.Fail)]
9+
[Index("IX_TeamPlayer_NumberPerTeam", Order = 1, IsUnique = true)]
1010
public int Number { get; set; }
1111

12+
// The index attribute must be placed on the FK not on the navigation property (team).
13+
[Index("IX_TeamPlayer_NumberPerTeam", Order = 2, IsUnique = true)]
14+
public int TeamId { get; set; }
15+
16+
// Its not possible to set an index on this property. Use the FK property (teamId).
1217
public virtual Team Team { get; set; }
1318
}
1419
}

0 commit comments

Comments
 (0)