Esempio n. 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new cricketapiContext(serviceProvider.GetRequiredService <DbContextOptions <cricketapiContext> >()))
            {
                if (!context.Player.Any())
                {
                    context.Player.AddRange(
                        new Player
                    {
                        Name    = "Brendon McCullum",
                        Country = "New Zealand",
                        Runs    = "6000",
                        Wickets = "0",
                        Catches = "200",
                        Url     = "https://i.pinimg.com/originals/38/50/7e/38507edd2df178149cbf1cb444ea198c.jpg"
                    }
                        );

                    context.SaveChanges();
                }
            }
        }
 public StatsController(cricketapiContext context, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
 }