Example #1
0
        private void InitializeDataBase()
        {
            options = new DbContextOptionsBuilder <PendenciaContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            using (var context = new PendenciaContext(options)){
                context.Pendencia.Add(new Pendencia {
                    Id = 1, Descricao = "Vitor", Data = "14/11/2002"
                });
                context.Pendencia.Add(new Pendencia {
                    Id = 2, Descricao = "Luiz", Data = "10/01/1999"
                });
                context.SaveChanges();
            }
        }
Example #2
0
        private void InitializeDataBase()
        {
            // Create a Temporary Database
            options = new DbContextOptionsBuilder <PendenciaContext>()
                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                      .Options;

            // Insert data into the database using one instance of the context
            using (var context = new PendenciaContext(options))
            {
                context.Pendencia.Add(new Pendencia {
                    Id = 1, Descricao = "Descrição 1", Data = "04/04/2021"
                });
                context.Pendencia.Add(new Pendencia {
                    Id = 2, Descricao = "Descrição 2", Data = "05/04/2021"
                });
                context.Pendencia.Add(new Pendencia {
                    Id = 3, Descricao = "Descrição 3", Data = "06/04/2021"
                });
                context.SaveChanges();
            }
        }