using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EF6_Code_First
{
    internal class Program
    {
        static void Main(string[] args)
        {
            using (var db = new FlughafenModell())
            {
                // Create and save a new country
                Console.Write("Enter a name for a new Country: ");
                var name = Console.ReadLine();
                var land = new Land { Name = name };
                //db.Lands.Add(land);
                db.SaveChanges();
                // Display all Countries from the database
                var query = from b in db.Lands
                            orderby b.Name
                            select b;
                Console.WriteLine("All countries in the database:");
                foreach (var item in query)
                {
                    Console.WriteLine(item.Name);
                }
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
    }

    public class Land
    {
        public int LandId { get; set; }

        [StringLength(50)]
        [Index("IX_Name", IsClustered = false, IsUnique = true)]
        public string Name { get; set; }

        public ICollection<Continent> Continent { get; set; }
    }

    public class Continent
    {
        public int ContinentId { get; set; }
        public string Name { get; set; }
    }
}