Beispiel #1
0
        private void AddDataToMemory()
        {
            using (var context = new NoteContext(ContextOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var note = new List <Note>()
                {
                    new Note()
                    {
                        Id = 1, Title = "Dog", Body = "Afternoon walk", IsComplete = true
                    },
                    new Note()
                    {
                        Id = 2, Title = "School", Body = "Do homework", IsComplete = true
                    },
                    new Note()
                    {
                        Id = 3, Title = "Errands", Body = "Grocery shop", IsComplete = false
                    },
                    new Note()
                    {
                        Id = 4, Title = "Work", Body = "Code new app", IsComplete = false
                    }
                };

                context.AddRange(note);
                context.SaveChanges();
            }
        }