- Relationship Using Code first with Existing database
- public class Product
- {
- public int ProductId { get; set; }
- public string Name { get; set; }
- public Category Category { get; set; }
- }
- public class Category
- {
- public int CategoryId { get; set; }
- public string Name { get; set; }
- public ICollection<Product> Products { get; set; }
- }
- modelBuilder.Entity<Product>()
- .HasMany(x => x.Category)