public static void Create(Pelicula a)
 {
     using (DBPORTALVIDEOSEntities db = new DBPORTALVIDEOSEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Peliculas.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Delete(int?id)
 {
     using (DBPORTALVIDEOSEntities db = new DBPORTALVIDEOSEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Pelicula pelicula = db.Peliculas.Find(id);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Update(Pelicula pelicula)
 {
     using (DBPORTALVIDEOSEntities db = new DBPORTALVIDEOSEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Peliculas.Attach(pelicula);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }