User379720387 posted
Attempting to set up a web api with EF Core. Scaffold was successful and have a Model folder with all Entities.
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using BtClassLibrary;
using BtApi.Model;
namespace BtApi.Controllers
{
[ApiController]
[Route("api/[controller")]
public class TransactionController: ControllerBase
{
private readonly AppDbContext context;
public TransactionController(AppDbContext context)
{
this.context = context;
}
[HttpGet]
public async Task<ActionResult<List<TransactionModel>>> Get() => await context.Transactions.ToList();
}
}
The highlighted area has the error message:
Severity Code Description Project File Line Suppression State
Error CS1061 'List<TransactionModel>' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'List<TransactionModel>' could be found (are you missing a using directive
or an assembly reference?) BtApi C:\Users\Robert\source\Repos\BtApi\Controllers\TransactionController.cs 24 Active
using System;
using System.Collections.Generic;
using System.Text;
namespace BtClassLibrary
{
public class TransactionModel
{
public int TransactionId { get; set; }
public int ClientId { get; set; }
public int BillNo { get; set; }
public bool IsBilled { get; set; }
public string Service { get; set; }
public decimal Charge { get; set; }
public decimal Tax { get; set; }
public DateTime TDate { get; set; }
public DateTime BDate { get; set; }
public bool IsPaid { get; set; }
}
}
And AppDbContext
using Microsoft.EntityFrameworkCore;
using BtClassLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BtApi
{
public class AppDbContext: DbContext
{
public DbSet<TransactionModel> Transactions { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
}
}
I am lost.