Are EF Core 3.1 ExecuteSqlRaw / ExecuteSqlRawAsync drop-in replacements for ExecuteSqlCommand / ExecuteSqlCommandAsync?

The rule is simple. EF Core 2.x has 3 ExecuteSqlCommand overloads: public static int ExecuteSqlCommand(this DatabaseFacade databaseFacade, RawSqlString sql, params object[] parameters); // 1 public static int ExecuteSqlCommand(this DatabaseFacade databaseFacade, RawSqlString sql, IEnumerable<object> parameters); // 2 public static int ExecuteSqlCommand(this DatabaseFacade databaseFacade, FormattableString sql); // 3 which in EF Core 3.x are mapped to public … Read more

GroupBy in EF Core 3.1 / EF Core 5.0 not working, even for the simplest example

Earlier EF/EF core automatically converted to client-side query evaluation when server-side evaluation was not possible. Grouping by a key without select is not something supported by SQL and would always have been a client-side operation. With EF 3.0+, they made it explicit on which query should run on server or on client. Technically it is … Read more

Use both AddDbContextFactory() and AddDbContext() extension methods in the same project

It is, it’s all about understanding the lifetimes of the various elements in play and getting those set correctly. By default the DbContextFactory created by the AddDbContextFactory() extension method has a Singleton lifespan. If you use the AddDbContext() extension method with it’s default settings it will create a DbContextOptions with a Scoped lifespan (see the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)