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

Entity Framework Core 2.0.1 Eager Loading on all nested related entities

Such feature officially does not exist currently (EF Core 2.0.2 and also the incoming 2.1). It’s been requested in Eager load all navigation properties #4851(Closed) and currently is tracked by Rule-based eager load (include) #2953 and Allow for declaring aggregates in the model (e.g. defining included properties or by some other means) #1985 (both in … Read more

SQLite Error 14: ‘unable to open database file’ with EF Core code first

i think the issue is that the EntityFramework Core can’t create folders by itself while using SQLite provider. Don’t know if the issue also appears when using other filebased database providers. i had the same issue: my datasource was something like: optionsBuilder.UseSqlite(@”Data Source=c:\foo_db\bar_db.db”); after i created the “foo_db” folder inside the c:\ drive, the problem … Read more

Entity Framework Core 7 connection certificate trust exception

it is not a bug in EF Core 7.0, instead it is improved security. Microsoft suggest following 3 solution, which ever applies to you. install a valid certificate. Add TrustServerCertificate=True to the connectionstring Add Encrypt=False to the connectionstring Old behavior SqlClient connection strings use Encrypt=False by default. This allows connections on development machines where the … Read more

Entity Framework Core jsonb column type

Based on H. Herzl comment: My final solution was something like this: public class MyTableClass { public int Id { get; set; } [Column(TypeName = “jsonb”)] public string Data { get; set; } } Migrations generated this: Data = table.Column<string>(type: “jsonb”, nullable: true), When updated the database with migrations, the Data column was created correctly … Read more