using Demo.Data; using Demo.Domain; using System; using System.Linq; namespace Demo.App { class Program { static void Main(string[] args) { using var context = new DemoContext(); //var seriA = new League() //{ // Country = "Italy", // Name = "Serie A" //}; //context.Leagues.Add(seriA); var seriB = new League() { Country = "Italy", Name = "Serie B" }; var seriC = new League() { Country = "Italy", Name = "Serie C" }; var seriA = context.Leagues.Single(x=>x.Name== "Serie A"); var milan = new Club { Name = "AC Milan", City = "Milan", DateOffEstablishment = new DateTime(2020, 4, 11), League = seriA }; context.AddRange(seriB,seriC,milan); var count = context.SaveChanges(); Console.WriteLine(count); Console.ReadKey(); } } }