Example #1
0
        private static void Set_DB(EfCoreDbContext context, AppSettings options)
        {
            if (context.Benutzer.Any())
            {
                var temp = context.Benutzer;
                return;
            }

            var benutzer = new Benutzer()
            {
                UserName = "******",
                Passwort = "12345",
            };

            var p = new Person()
            {
                Name    = "Riesner",
                Vorname = "Rene",
                Adresse = new Adresse()
                {
                    Plz = "15344",
                    Ort = "Strausberg"
                }
            };

            p.Benutzer.Add(benutzer);

            context.Add(p);
            context.SaveChanges();
        }
Example #2
0
        public static void Initialize(EfCoreDbContext context, AppSettings options)
        {
            //if (!options.InMemory)
            //{
            //    try
            //    {
            //        context.Database.Migrate();
            //    }
            //    catch
            //    {

            //    }
            //}

            context.Database.EnsureCreated();

            Set_DB(context, options);
        }