Hi. I need to insert and immediately save changes to db, but for some reason there is no data in the db after saving changes. Its inserting the data only after controller was totally executed.
This is simplified example of my code:
public class Car : Entity
{
public string Name { get; set; }
}
public interface ICarRepository : IRepository<Car>
{
Task SaveChangesAsync();
}
public class CarRepository : BaseRepository<Car>, ICarRepository
{
public CarRepository(IDbContextProvider<PropertyIntelDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task SaveChangesAsync()
{
await Context.SaveChangesAsync();
}
}
public async Task<ActionResult> InsertCar()
{
await _carRepository.InsertAsync(new Car
{
Name = "test"
});
await _carRepository.SaveChangesAsync();
return Content("Ok");
}
Should be something simple. What am I doing wrong? How to force insert the data?