I'm using VS Code and following an ASP.NET Core/ EF Core tutorial and admit I'm not quite clear on how the async, await and Task do (well, I know the first two, but not the third.) I am implementing a repository for the first time, and a UnitofWork Class and Interface to go with it. Here is the UnitofWork Class:
using System.Threading.Tasks;
namespace vega.Persistence
{
public class UnitOfWork : IUnitOfWork
{
private readonly VegaDbContext context;
public UnitOfWork(VegaDbContext context)
{
this.context = context;
}
public async Task CompleteAsync()
{
await context.SaveChangesAsync();
}
}
}
In addition to the subject-line error shown by VS-Code intellisense when I hover over the CompleteAsync action name, I get this:
'UnitOfWork.CompleteAsync()': not all code paths return a value [AppName]
Other perhaps relevant snippets:
using System;
using System.Threading.Tasks;
namespace vega.Persistence
{
public interface IUnitOfWork
{
Task CompleteAsync();
}
}
In my Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
// Add Repository and UnitOfWork --scoped (instance persits for life of request),
// not Transient or Singleton
services.AddScoped<IVehicleRepository, VehicleRepository>();
services.AddScoped<IUnitOfWork, UnitOfWork>();
}