on-internet
← Community

Improving EF Core SQLite queries and seeding (AnyAsync, AddRangeAsync) and understanding DbContext

Stack Overflow ·

I'm using an SQlite database and I wanted to know if there is a better or shorter way to do this. I made the following code as practice example. In ServersGet, I currently check db.ServerNodes.Count() > 0 before calling ToArrayAsync(), and in SeedPost I call Add(node) inside a loop. Should I use AnyAsync() instead of Count() > 0 and AddRangeAsync() for seeding, and are there other EF Core improvements I should make here? This is my Program.cs using Microsoft.AspNetCore.Hosting.Server; using Microsoft.EntityFrameworkCore; namespace ServerMS { public class Program { public static void Main(strin

Comments

Sign in or sign up to comment and upvote.

No comments yet.