Exemple #1
0
 public static void UpdateModel(List <Models.Book> books)
 {
     //var optionsBuilder = new DbContextOptionsBuilder();
     //optionsBuilder.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MyStuff;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
     //optionsBuilder.UseLoggerFactory(MyConsoleLoggerFactory);
     using (var BookCtx = new MyStuffdbContext(new DbContextOptions <MyStuffdbContext>()))
     {
         BookCtx.FavoriteBooks.AddRange(books);
         //BookCtx.FavoriteBooks.UpdateRange(books);
         BookCtx.SaveChanges();
     }
 }
 public Project Add(Project project)
 {
     _context.Projects.Add(project);
     _context.SaveChanges();
     return(project);
 }