aboutsummaryrefslogtreecommitdiff
path: root/Main
diff options
context:
space:
mode:
Diffstat (limited to 'Main')
-rw-r--r--Main/Program.cs24
1 files 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<Article>() {
+ 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) {