Tagging EF Core Queries

.NET Core 2.2 introduce a small feature known as Query Tags. It allows you to annotate queries generated by EF Core. This is super useful for debugging purposes, after all one of the main complains you often hear about EntityFramework is the over completed SQL statements it generates. I am currently working on a project called Chinook, it demonstrates how to build a JSON:API on .NET Core. The project uses EF Core to query a SQLite database....

December 9, 2020 · Yunier

SQLite - No Such Table Error

Are you using SQLite as an in-memory provider for EF Core on your Unit/Integration test? If you are, you may come across the following exception when creating the in-memory database. As you can see from the exception, the error is “SQLite Error 1: ’no such table vPet’” which is odd because vPet is defined as a SQL view on my DbContext, not a SQL table. Here is my PetsDbContext. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 public class PetsDbContext : DbContext { // Rest of code omitted for brevity public DbSet<Pet> Pets { get; set; } public PetsDbContext() { } public PetsDbContext(DbContextOptions<PetsDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { // Rest of code omitted for brevity modelBuilder....

September 19, 2020 · Yunier