I've just started to work with Entity Framework Core 6. I am working with a sample database where I have a many to many relationship.
I created my database on SQL server. I created three tables: Service, Document, ServiceDocs (used as a Junction Table).
Then I did :
scaffolf-dbcontext
both classes have been generated except the junction table ServiceDocs. My question is: How can I add elements to the junction table and get data from it without the class of the junction table?
Thank you for your help.
Class document:
public partial class Document
{
public Document()
{
Services = new HashSet<Service>();
}
public Guid DocumentId { get; set; }
public string? DocTitre { get; set; }
public virtual ICollection<Service> Services { get; set; }
}
public partial class Service
{
public Service()
{
Docs = new HashSet<Document>();
}
public Guid ServiceId { get; set; }
public string? Libelle { get; set; }
public virtual ICollection<Document> Docs { get; set; }
}
Here some screenshots : Database diagram Document