From 9ed58b9d5d3babef95be122d12eda3239c43a738 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 10 Feb 2019 15:00:24 +0000 Subject: Tested adding a range of articles with duplicate titles --- Main/Program.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Main/Program.cs b/Main/Program.cs index 4ad64af..0e88199 100644 --- a/Main/Program.cs +++ b/Main/Program.cs @@ -50,10 +50,28 @@ namespace Main { private static async Task Main(string[] args) { using (var db = new DatabaseContext()) { + int start; try { - await db.Articles.AddAsync(new Article() { - Title = "TITLE" - }); + start = db.Articles.Last().ArticleID; + } + catch (Exception) { + start = 0; + } + try { + var articles = new List
() { + new Article() { + Title = "TITLE1" + }, + new Article() { + Title = "TITLE2" + }, + new Article() { + Title = "TITLE3" + } + }; + await db.AddRangeAsync(articles.Select((article, index) => new Article() { + ArticleID = index + start, + Title = article.Title})); await db.SaveChangesAsync(); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { -- cgit v1.2.3-13-gbd6f