for (int row = 2; ws.Cells[row, col].Value != null; row++ )
{
entities.Music.Add(new Music
{
...
});
entities.SaveChanges();
return View("Index");
}
You have a
return
statement
inside your
for
loop. As a result, the loop will execute once and immediately return.
Move the
SaveChanges
and
return
lines
outside of the
for
loop:
for (int row = 2; ws.Cells[row, col].Value != null; row++ )
{
entities.Music.Add(new Music
{
...
});
}
entities.SaveChanges();
return View("Index");