Example #1
0
        public static void Initialize(Labo6Context context)
        {
            context.Database.EnsureCreated();

            // Look for any Clients.
            if (context.Clients.Any())
            {
                return;       // DB has been seeded
            }

            var clients = new Client[]
            {
                new Client {
                    CliPrenom = "Justin", CliNom = "Trudeau", cliDateNaiss = Convert.ToDateTime("2000/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                new Client {
                    CliPrenom = "Stephen", CliNom = "Harper", cliDateNaiss = Convert.ToDateTime("2001/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                new Client {
                    CliPrenom = "Pauline", CliNom = "Marois", cliDateNaiss = Convert.ToDateTime("2002/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                new Client {
                    CliPrenom = "Jean", CliNom = "Charest", cliDateNaiss = Convert.ToDateTime("2003/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                }
            };

            foreach (Client c in clients)
            {
                context.Clients.Add(c);
            }
            context.SaveChanges();
        }
Example #2
0
        //private static Labo6Context _context;

        //public PopulateDatabase(Labo6Context context)
        //{
        //    _context = context;
        //}

        public static void EnsurePopulated(Labo6Context context)
        {
            context.Database.EnsureCreated();
            //Labo6Context context = app.ApplicationServices
            //    .GetRequiredService<Labo6Context>();
            if (!context.Clients.Any())
            {
                context.Clients.AddRange(
                    new Client {
                    CliPrenom = "Justin", CliNom = "Trudeau", cliDateNaiss = Convert.ToDateTime("2000/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                    new Client {
                    CliPrenom = "Stephen", CliNom = "Harper", cliDateNaiss = Convert.ToDateTime("2001/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                    new Client {
                    CliPrenom = "Pauline", CliNom = "Marois", cliDateNaiss = Convert.ToDateTime("2002/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                },
                    new Client {
                    CliPrenom = "Jean", CliNom = "Charest", cliDateNaiss = Convert.ToDateTime("2003/10/10"), CliRue = "", CliVille = "", CliTelephone = ""
                }
                    );

                context.SaveChanges();
            }
        }
Example #3
0
 public ClientEFRepository(Labo6Context context)
 {
     _context = context;
 }