I am using .NET CORE 3.1 version and code first approach for Database creation. My model is in c# :
[Table("ProfileStore")]
public class ProfileStore : BaseEntity
{
[ForeignKey("Profile")]
public int ProfileId { get; set; }
[ForeignKey("Store")]
public int StoreId { get; set; }
public virtual Stores.Store Store { get; set; }
public virtual Profile Profile { get; set; }
}
Here Profile and Store both are different table and I am adding mapping of this two table in this table. Now I want to add row with unique combination only. How can I do that?
Sample Data Will be :
Id ProfileId StoreId
1 1 1
2 1 2
3 2 1
4 2 3
5 1 1 <------- This is should not insert when I will try to insert this.