Skip to content

Instantly share code, notes, and snippets.

@lucasapoena
Last active February 21, 2022 11:56
Show Gist options
  • Save lucasapoena/cc774adce4c9302e3b33880ad3955fd0 to your computer and use it in GitHub Desktop.
Save lucasapoena/cc774adce4c9302e3b33880ad3955fd0 to your computer and use it in GitHub Desktop.
Relacionamento Many-to-Many no Entity Framework 3.1 (EF Core 3.1)
using System.Collections.Generic;
namespace Example.Dotnet
{
public class Product
{
public long ProductId { get; set; }
public string Name { get; set; }
public virtual ICollection<ProductCategory> ProductCategories { get; set; }
}
public class Category
{
public long CategoryId { get; set; }
public string Name { get; set; }
public virtual ICollection<ProductCategory> ProductCategories { get; set; }
}
public class ProductCategory
{
public int ProductId { get; set; }
public int CategoryId { get; set; }
public virtual Product Product { get; set; }
public virtual Category Category { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment