I need association table to realize the M:M relationship between InspChars and Materials, but there should be an additional field. That is why I create another table InspCharsToMaterials. Everything is working, but ef creates its own auto-generated association table that I don't need at all.
How to cope with it? How to switch off this possibility of ef (only for many-to-many).
[Table("tbl_Materials")]
public class Material
{
[Key]
public int key { get; set; }
[Required]
[Column(TypeName = "NVARCHAR")]
[StringLength(18)]
public string MaterialID { get; set; }
[Required]
[Column(TypeName = "NVARCHAR")]
[StringLength(128)]
public string MaterialName { get; set; }
[Column(TypeName = "bit")]
public bool Deleted { get; set; }
public virtual ICollection<InspectionCharacteristic> InspCharLinks { get; set; }
}
[Table("tbl_InspectionCharacteristic")]
public class InspectionCharacteristic
{
[Key]
[Required]
public int key { get; set; }
[Required]
[Column(TypeName = "NVARCHAR")]
[StringLength(40)]
public string InspCharID { get; set; }
[Required]
[Column(TypeName = "NVARCHAR")]
[StringLength(40)]
public string InspCharName { get; set; }
[Column(TypeName ="BIT")]
public bool IsCatalogType { get; set; }
/*[Column(TypeName = "NVARCHAR")]
[StringLength(8)]
public string CatalogGroupLink { get; set; }*/
[Column("CatalogGroupID")]
public int? CatalogGroupKeyID { get; set; }
//public virtual CatalogGroup CatalogGroup { get; set; }
public virtual ICollection<Material> Materials { get; set; }
}
And my association table:
[Table("tbl_InspCharToMaterials")]
public class InspCharToMaterial
{
[Key]
public int key { get; set; }
public virtual Material Material { get; set; }
public virtual InspectionCharacteristic InspectionCharacteristic { get; set; }
public bool Deleted { get; set; }
}