Added try/catch for 'Demo data' project for error cases

This commit is contained in:
KharchenkoVV 2021-09-07 17:39:28 +05:00
parent 42b9849ae9
commit 9d80c28c1b

View File

@ -18,6 +18,8 @@ namespace AsbCloudDbDemoData
return;
}
try
{
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
.Options;
@ -73,15 +75,15 @@ namespace AsbCloudDbDemoData
);
demoContext.AddRange(
new RelationCompanyWell{ IdWell = 1, IdCompany = 1},
new RelationCompanyWell{ IdWell = 2, IdCompany = 1},
new RelationCompanyWell{ IdWell = 3, IdCompany = 1},
new RelationCompanyWell{ IdWell = 4, IdCompany = 1},
new RelationCompanyWell{ IdWell = 5, IdCompany = 1},
new RelationCompanyWell{ IdWell = 6, IdCompany = 1},
new RelationCompanyWell{ IdWell = 7, IdCompany = 1},
new RelationCompanyWell{ IdWell = 8, IdCompany = 1},
new RelationCompanyWell{ IdWell = 9, IdCompany = 1}
new RelationCompanyWell { IdWell = 1, IdCompany = 1 },
new RelationCompanyWell { IdWell = 2, IdCompany = 1 },
new RelationCompanyWell { IdWell = 3, IdCompany = 1 },
new RelationCompanyWell { IdWell = 4, IdCompany = 1 },
new RelationCompanyWell { IdWell = 5, IdCompany = 1 },
new RelationCompanyWell { IdWell = 6, IdCompany = 1 },
new RelationCompanyWell { IdWell = 7, IdCompany = 1 },
new RelationCompanyWell { IdWell = 8, IdCompany = 1 },
new RelationCompanyWell { IdWell = 9, IdCompany = 1 }
);
demoContext.WellOperations.AddRange(
@ -297,5 +299,10 @@ namespace AsbCloudDbDemoData
else
Console.WriteLine("Ошибка при добавлении данных");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}