I am trying to see the SQLs executed by the Entity Framework, I use version 6.
I'm following this guide .
I made a new DBContext using the graphical interface. 5 tables only.
The code is inside a Controller Web API2:
public class TAGsController : ApiController
{
private MEUDB db = new MEUDB();
// GET: api/TAGs/5
[Route("{Key}/api/tag/tag/{id}")]
[ResponseType(typeof(TAG))]
public async Task<IHttpActionResult> GetTAG(long id)
{
db.Database.Log = Console.Write;
TAG tAG = await db.TAGs.FindAsync(id);
if (tAG == null)
{
return NotFound();
}
return Ok(tAG);
}
}
When debugging I went to the Find line and it returned the following in the output window:
The thread 0x8188 has exited with code 259 (0x103).
What am I doing wrong? According to the guide should be just that.
Edited: More information
When doing everything equal, only using Find()
, without Async()
, it works.
TAG tAG = await db.TAGs.Find(id);
Is there any extra setting for this? Or any special care?