I am having trouble when inserting multiple records. When I try to insert 2 records the debugger shows the count of 2 but it only saves 1 record.
This is my code in my manager class
public void Create(IEnumerable<CollectionModel> p )
{
collection module = new collection();
foreach (var asa in p)
{
module.AccountId = 1;
module.Amount = asa.Amount;
module.NameSou = asa.NameSou;
module.Date = asa.Date;
module.CreatedDatetime = DateTime.Now;
module.UpdatedDatetime = DateTime.Now;
_context.collection.Add(module);
}
_context.SaveChanges();
}
_context.collection.Add(module);inside for loop