public static void AddAppIfNew(App app) { if (app.Validate()) { using (AppRssDatabase db = new AppRssDatabase()) { int existingCount = db.Apps.Count(x => x.Name == app.Name); if (existingCount == 0) { db.Apps.Add(app); db.SaveChanges(); } } } }