{"id":296190,"date":"2019-12-21T21:00:14","date_gmt":"2019-12-21T21:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296190"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296190","title":{"rendered":"\u041c\u044b \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u2014 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 MSTest"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481474\/\">\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f<\/h4>\n<p>  \u0423\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u044c \u0432\u0435\u043a\u0430 \u043f\u0440\u0430\u0437\u0434\u043d\u0443\u0435\u043c \u043c\u0438\u043b\u043b\u0435\u043d\u0438\u0443\u043c, \u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0449\u0451 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c\u2026 \u0421\u043b\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0443\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0443 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435\u2026 \u0414\u0430 \u0447\u0435\u0433\u043e \u0443\u0436 \u0442\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u0445, \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043c\u0435\u0440\u0442\u043d\u044b\u043c \u0438 \u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u0441\u043d\u043e\u0432\u0430 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c! \u041a\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u0432\u0449\u0438\u0446\u0443 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u2014 \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u044a\u0435\u0441\u0442\u044c \u0435\u0433\u043e! \u0414\u0430\u0436\u0435 \u0431\u044b\u0432\u0430\u043b\u044b\u0435 \u043e\u0445\u0440\u0430\u043d\u043d\u0438\u043a\u0438 \u044f\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u2014 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0433\u043d\u0430\u0442\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0435. \u0418 \u043d\u0435 \u0434\u043e\u043a\u0430\u0436\u0435\u0448\u044c \u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443\u0436 \u0441\u0430\u043c \u0413\u043e\u0441\u043f\u043e\u0434\u044c \u0411\u043e\u0433 \u043d\u0435 \u0433\u043d\u0443\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TDD \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0412\u0435\u043b\u0438\u043a\u0438\u0439 \u041f\u043e\u0442\u043e\u043f), \u0442\u043e \u043d\u0430\u043c \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0441\u0430\u043c \u0431\u043e\u0433 \u0432\u0435\u043b\u0435\u043b\u2026<\/p>\n<p>  \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0432\u043e\u0434\u043e\u0432 \u0440\u0430\u0441\u0442\u0451\u0442 \u2014 \u043f\u043e\u0447\u0435\u043c\u0443? \u0414\u0430 \u0432\u0441\u0451 \u043f\u043e\u0442\u043e\u043c\u0443 \u0436\u0435! TDD! \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439 \u2014 \u043f\u043e\u0442\u043e\u043c \u0436\u0435\u043d\u0438\u0441\u044c! \u041d\u0435\u0442, \u0434\u043e\u0432\u0435\u0440\u0447\u0438\u0432\u044b\u0435 \u043c\u0443\u0436\u0438\u0447\u043a\u0438 \u0432 \u0440\u0430\u0441\u0445\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044b\u0445 \u0442\u0443\u043b\u0443\u043f\u0430\u0445, \u043f\u0430\u0434\u043a\u0438\u0435 \u043d\u0430 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0441\u0435\u043a\u0441 \u0440\u0435\u043a\u043b\u0430\u043c\u0443, \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043c\u043e\u043b\u043e\u0434\u0443\u044e \u0436\u0435\u043d\u0443 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u2026 <\/p>\n<p>  \u041d\u0443 \u043c\u044b \u0442\u043e \u0441 \u0432\u0430\u043c\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435!<\/p>\n<h4>\u042f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0443\u0437\u043d\u0430\u044e \u043f\u043e \u043f\u043e\u0445\u043e\u0434\u043a\u0435\u2026<\/h4>\n<p>  \u0418 \u0432\u043e\u0442 \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 code first \u0442\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e DAL \u0441\u043b\u043e\u044f \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432 VisualStudio \u0442\u0435\u0441\u0442\u0430\u0445?<\/p>\n<p>  \u0418 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0434\u043b\u044f EntityFramework, \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u043e\u0439 \u043b\u043e\u0432\u043a\u043e\u0441\u0442\u0438 \u0440\u0443\u043a \u043f\u043e\u0434 \u043e\u0434\u0435\u044f\u043b\u043e\u043c \u0438 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441 fake-\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 \u0440\u0430\u0441\u0447\u0435\u0445\u043b\u044f\u0435\u043c VS, \u043e\u0434\u0435\u0432\u0430\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 \u0438 \u0432\u043f\u0435\u0440\u0451\u0434! (\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0435\u0432\u0430\u044e\u0441\u044c \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0434\u0435\u0436\u0434\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tg\/pv\/kw\/tgpvkwgvjzb4zf7tt-navdbcazi.jpeg\" alt=\"image\">  <\/div>\n<\/div>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0412\u0441\u0435\u043c \u043b\u0435\u0436\u0430\u0442\u044c, \u044d\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435!<\/h4>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043b\u0443\u0447\u0430\u0439 \u0438\u0437 \u0436\u0438\u0437\u043d\u0438:<\/b><\/p>\n<div class=\"spoiler_text\">\u0420\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"plaintext\">ObjectLink link = this.ObjectLinks.ToList().Where(x =&gt; x.SpotCode.ToLowerInvariant() == code.ToLowerInvariant()).SingleOrDefault();<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0431\u044b\u043b \u043f\u043e\u043a\u0440\u044b\u0442 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0443\u0441\u043f\u0435\u043b \u2014 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u043c. \u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0438 \u044f \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u0438\u043b\u0441\u044f\u2026 \u043d\u043e \u0411\u0438\u043b\u043b \u0413\u0435\u0439\u0442\u0441 \u043f\u043e\u0434\u043a\u0440\u0430\u043b\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e\u2026 <\/p>\n<p>  \u0421\u0442\u043e\u044f\u043b\u0430 \u043f\u043e\u044d\u0442\u0438\u0447\u043d\u0430\u044f \u043f\u0438\u0442\u0435\u0440\u0441\u043a\u0430\u044f \u043e\u0441\u0435\u043d\u044c, \u0441\u043d\u0435\u0433 \u0441 \u0434\u043e\u0436\u0434\u0451\u043c \u043d\u0435\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b \u043b\u0438\u0446\u043e, \u0433\u0440\u044f\u0437\u044c \u0432\u0435\u0441\u0435\u043b\u043e \u0441\u0442\u0435\u043a\u0430\u043b\u0430 \u0441\u043e \u0448\u0442\u0430\u043d\u0438\u043d \u0438 \u0441\u043a\u0432\u043e\u0437\u044c \u0440\u0430\u0441\u0442\u0451\u043a\u0448\u0443\u044e\u0441\u044f \u043a\u043e\u0441\u043c\u0435\u0442\u0438\u043a\u0443 \u0443\u043b\u044b\u0431\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0434\u0435\u0432\u0447\u0451\u043d\u043a\u0438, \u043e\u0431\u043b\u0438\u0432\u0430\u044f\u0441\u044c \u043f\u0440\u043e\u0435\u0437\u0436\u0430\u044e\u0449\u0438\u043c\u0438 \u043c\u0438\u043c\u043e \u0433\u0440\u0443\u0437\u043e\u0432\u0438\u043a\u0430\u043c\u0438\u2026 \u044f \u0443\u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0437\u0430 \u043f\u0430\u043b\u044c\u0446\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u043e\u0432\u044b\u0440\u044f\u0442\u044c \u0432 \u043d\u043e\u0441\u0443, \u043a\u0430\u043a \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u0432\u0430\u0440\u043d\u043e, \u0431\u0435\u0437 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043e\u0439\u043d\u044b, \u043f\u0435\u0440\u0435\u0434 \u0441\u0430\u043c\u044b\u043c \u0440\u0430\u0441\u0441\u0432\u0435\u0442\u043e\u043c Microsoft \u043f\u043e\u0440\u0435\u0437\u0430\u043b\u0430 \u043a\u043e\u043b\u044e\u0447\u0443\u044e \u043f\u0440\u043e\u0432\u043e\u043b\u043e\u043a\u0443 \u0438 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 core 3.0. \u0425\u043e\u0441\u0442\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u044f \u0442\u043e\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u0447\u0435\u0433\u043e \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u0445\u043e\u0434\u0438\u0442\u044c \u2014 \u044f \u0447\u0442\u043e, \u0445\u0443\u0436\u0435 \u0445\u043e\u0441\u0442\u0435\u0440\u0430? \u0432\u0441\u0451 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0432\u0440\u043e\u0434\u0435 \u0438 \u0432\u044b\u043a\u0430\u0442\u0438\u043b \u0430\u043f\u0434\u0435\u0439\u0442\u2026 \u0430 \u0441\u043b\u0435\u0434\u043e\u043c \u0432\u044b\u043a\u0430\u0442\u0438\u043b \u0433\u043b\u0430\u0437\u0430! \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b! \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u044f \u0436\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u2014 \u0447\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f?<\/p>\n<p>  \u0410 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0447\u0442\u043e: \u0441\u0442\u0430\u0440\u0438\u043d\u0430 \u0411\u0438\u043b\u043b\u0438 \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043f\u0438\u043b\u0438\u0442\u044c \u0438\u0437 LINQ ToLowerInvariant\u2026 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u2026 \u0435\u0441\u043b\u0438 \u0431\u044b \u043a\u043e\u0434 \u0431\u044b\u043b \u043f\u043e\u043a\u0440\u044b\u0442 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u044f \u0431\u044b \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u0425\u043e\u0440\u043e\u0448\u043e \u0447\u0442\u043e \u044f \u0441\u0430\u043c \u0432\u0441\u0451 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u043c, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0443 \u0432\u0435\u0434\u044c \u043a\u0440\u0430\u0441\u043d\u0435\u0442\u044c \u0441\u0442\u044b\u0434\u043d\u043e\u2026 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 deploy.  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u043f\u0440\u0438\u0431\u043e\u0440\u044b \u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/h4>\n<p>  Microsoft VisualStudio 2019<br \/>  asp.net Core 3.1 (\u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u0443\u0434\u0438\u0435\u0439, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u043d\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 install other frameworks)<br \/>  SQL Server Express (\u0438\u0434\u0451\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u0443\u0434\u0438\u0435\u0439)<br \/>  Git Extension to visual studio (\u0438\u0434\u0451\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435)<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e MSTest. \u0412 \u043c\u0438\u043b\u0438\u0446\u0438\u044e \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430\u0441 \u0437\u0430 \u044d\u0442\u043e \u043d\u0435 \u0437\u0430\u0431\u0435\u0440\u0443\u0442.<\/p>\n<p>  \u0412 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0437\u0434\u0430\u043d\u0438\u044f\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Mock-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u0418\u0434\u0435\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0445\u043e\u0440\u043e\u0448\u0430\u044f, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0447\u043d\u0443\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438.<br \/>  \u0422\u043e\u0433\u0434\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 mock \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0441\u0430\u043c\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0410 \u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u2014 Control+\u0421 \u2014 Control+V! \u043c\u044b \u0432\u0441\u0435 constraints \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 EF, \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, DataAnnotations \u0438\u043b\u0438 FluentAPI \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u0435\u043c \u0432 mock-\u0441\u043b\u043e\u0435. \u0410 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u2026 \u0430\u044f\u044f\u0439, \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0438\u043d, \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u043c\u2026 \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u043e! <\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 mock, \u0438 \u043c\u044b \u0442\u0430\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0448\u0438\u0431\u043b\u0438\u0441\u044c \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u2014 \u0442\u0435\u0441\u0442 \u043d\u0430 mock \u043f\u0440\u043e\u0439\u0434\u0451\u0442, \u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430?<\/p>\n<p>  \u041c\u0435\u043d\u044f \u044d\u0442\u043e \u0432\u0441\u0451 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<p>  \u0418\u0434\u0435\u044f \u043f\u0440\u0438\u0448\u043b\u0430 \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0437 \u0422\u0420\u0418\u0417: <i>\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044d\u0442\u043e \u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0435\u0451 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f<\/i>. \u0418 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441\u0430\u043c\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u0418 \u0443 \u043c\u0435\u043d\u044f \u0432\u0440\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u042d\u0442\u0438\u043c \u0438 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442.<\/p>\n<p>  \u041c\u0438\u043d\u0443\u0441\u044b mock:<\/p>\n<ul>\n<li>\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u043b\u0438 \u0431\u044b \u0442\u0435\u0441\u0442\u044b<\/li>\n<li>\u0442\u0435\u0441\u0442\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0433\u0440\u044f\u0437\u043d\u044b\u043c\u0438, \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u0434\u0430<\/li>\n<li>\u0441\u043b\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c migrations<\/li>\n<li>\u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u043e\u043c, \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0432\u0435\u0434\u043e\u043c\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/li>\n<li>\u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0431\u0430\u0437\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043b\u0435\u0437\u0442\u044c \u0432 mock \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043c \u0432\u0441\u0451 \u0442\u043e\u0436\u0435<\/li>\n<\/ul>\n<p>  \u041f\u043b\u044e\u0441\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435:<\/p>\n<ul>\n<li>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043d\u0430 \u0431\u043e\u0435\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/li>\n<li>\u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0449\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0445 \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0435<\/li>\n<li>\u043c\u044b \u0441\u0430\u043c\u0438 \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u0431\u0430\u0437\u044b \u043d\u0443\u043c\u0435\u0440\u0443\u044f \u0442\u0435\u0441\u0442\u044b (\u0432 MSTest \u043e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443)<\/li>\n<li>\u0432\u0438\u0434\u043d\u043e \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0442 (\u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u0432\u0438\u0434\u0435\u043d \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u2014 \u0432 10 \u0440\u0430\u0437 \u0434\u043e\u043b\u044c\u0448\u0435, \u0432 2 \u0440\u0430\u0437\u0430, \u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0442)<\/li>\n<li>\u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b<\/li>\n<\/ul>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u043a\u043e\u043f\u0430\u043b\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439, \u043d\u043e \u043c\u044b \u0438\u0445 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0435\u0448\u0438\u043c, \u0438 \u0434\u0430 \u043f\u0440\u0435\u0431\u0443\u0434\u0435\u0442 \u0441 \u0432\u0430\u043c\u0438 \u043c\u043e\u0439 \u043a\u0430\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u044d\u043a\u0435\u043d\u0434!<\/p>\n<p>  \u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 ASP.Net Core 3.1 Web Application (Model-View-Controller), Authentication \u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 Individual User Accounts (Store user accounts in-app) \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n1\/oq\/5c\/n1oq5cv0fxxqnuu0sdgdwda7xem.jpeg\" alt=\"image\"><\/p>\n<p>  \u0421 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0441\u043d\u0438\u043c\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 git, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441 \u043d\u0435\u0439 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<p>  <a href=\"https:\/\/github.com\/3263927\/Habr_1\" rel=\"nofollow\">github.com\/3263927\/Habr_1<\/a><\/p>\n<p>  <b>Snapshot: Snapshot_0_ProjectCreated<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043e\u0434\u0438\u043d, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u2014 \u043e\u043d \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0442\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439, \u0432\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u0440\u044f\u043c\u043e \u0432 Visual Studio, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u0441\u0451 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 VS. \u041c\u043e\u0436\u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0448\u044c, \u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u043a\u0430\u0442\u0438\u0432 commit \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0442\u043a\u0443. \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0441\u0438\u043b, \u0432\u0441\u0435\u043c \u0441\u043e\u0432\u0435\u0442\u0443\u044e. \u0418 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 github \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e. \u041f\u0440\u0430\u0432\u0434\u0430 \u0442\u0430\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0447\u0443\u0432\u0430\u043a \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0432\u0441\u0451 \u043f\u043e\u0443\u0434\u0430\u043b\u044f\u043b\u2026 \u0422\u0430\u043a \u0447\u0442\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0432\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0435\u0449\u0451 \u043a\u043b\u0430\u0434\u0443 \u0432 Dropbox \u0438 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u044e \u0432\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u044e \u0432 Google Drive \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438. \u041d\u0443 \u0438 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 SD 120 \u0433\u0438\u0433\u043e\u0432, \u0442\u0443\u0434\u0430 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e \u0437\u0430\u043f\u0430\u0441, \u0432\u0434\u0440\u0443\u0433 \u0447\u0442\u043e\u2026 \u0410 \u043f\u0430\u0440\u0430 \u0444\u043b\u0435\u0448\u0435\u043a \u0441 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043f\u043e \u043a\u0430\u0440\u043c\u0430\u043d\u0430\u043c \u0442\u0430\u043a \u0432\u043e\u0431\u0449\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e!  <\/div>\n<\/div>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0432\u0435\u0442\u043a\u0438. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 Snapshot \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0451\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>  \u042f \u0441\u043e\u0437\u0434\u0430\u043c \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443 (Branch) \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 VisualStudio, \u0438 \u043d\u0430\u0437\u043e\u0432\u0443 \u0435\u0451 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u00ab\u0421\u0435\u0441\u0442\u0440\u0430 \u0422\u0430\u043b\u0430\u043d\u0442\u0430\u00bb (\u0448\u0443\u0442\u043a\u0430, Snap_1_DataBases).<\/p>\n<p>  <b>\u0446\u0435\u043b\u044c: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0431\u0430\u0437\u044b<\/b>.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0431\u0430\u0437\u044b.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0431\u0430\u0437\u044b \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 3 \u2014 \u043e\u0434\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f (\u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435), \u0434\u0440\u0443\u0433\u0430\u044f production (\u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0440\u0430\u0431\u043e\u0447\u0430\u044f) \u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0447\u0430\u044f (\u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u0430\u0439\u0442\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 DEBUG). <\/p>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f: <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u0439\u0442 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Habr1_Local<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043b\u043e\u0436\u0438\u043c \u043a\u043e\u0434 \u0432 production \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Habr1_Production<\/li>\n<li>\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0431\u0430\u0437\u0443 Habr1_Test \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0451<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0435 \u2014 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0435, Debug \u0438 Release. \u042d\u0442\u043e \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043e\u043d\u0430 \u0440\u0435\u0448\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u2014 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0443 \u043d\u0430\u0441 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0430 \u0431\u0430\u0437\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0451\u2026 \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u0430\u043c\u043e\u0433\u043e Visual Studio!<\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b appsettings.json<\/p>\n<p>  \u0422\u0430\u043c \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"json\">\"ConnectionStrings\": {     \"DefaultConnection\": \"Server=(localdb)\\\\mssqllocaldb;Database=aspnet-WebApp-[\u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0446\u0438\u0444\u0440\u044b, \u0443 \u0432\u0441\u0435\u0445 \u0440\u0430\u0437\u043d\u044b\u0435];Trusted_Connection=True;MultipleActiveResultSets=true\"   },<\/code><\/pre>\n<p>  \u0422\u0443\u0434\u0430 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0432 production \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0430\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0423 \u043d\u0430\u0441 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0431\u0430\u0437\u044b (local \u0438 test, production \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u2014 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 release \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041f\u043e\u0442\u043e\u043c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443).<\/p>\n<p>  \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?<\/p>\n<p>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Visual Studio \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 visual studio: <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qa\/8k\/nr\/qa8knrxqxt8komoewxxf-b-s2qs.jpeg\" alt=\"image\"><\/p>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u0442 DEBUG \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u043a\u0443\u0434\u0430 \u0443\u0433\u043e\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f, \u043a\u0430\u043a\u0430\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f.<\/p>\n<p>  \u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 colocation \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430\u0445. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448 asp.net \u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0430 \u043a \u0431\u0430\u0437\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439, \u0438 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d. \u0412\u043e\u0442 \u0432 release \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u044d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f debug \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0430\u0448\u0435\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439. \u0410 test \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u2014 \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u0441\u0442\u0435\u0440\u0435\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0437\u0430\u0431\u044b\u0432 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u043c\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u2014 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 view -&gt; SQL server object explorer<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mk\/-1\/tc\/mk-1tcplz6dtcpzupszdzpesh84.jpeg\" alt=\"image\"><\/p>\n<p>  (\u0418\u043c\u044f \u043c\u043e\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u044f \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0442\u0440\u0443, \u0430 \u0442\u043e \u0432\u044b \u043c\u0435\u043d\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u043f\u043e IP \u0438 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430\u0431\u044c\u0451\u0442\u0435).<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e (localdb)\\ProjectsV13. \u043d\u0435 \u0437\u043d\u0430\u044e \u043f\u043e\u0447\u0435\u043c\u0443, \u043c\u043e\u0439 SQL \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0442\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043b.<br \/>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <\/p>\n<pre><code class=\"json\">\"DefaultConnection\": \"Server=(localdb)\\\\ProjectsV13;Database=Habr1_Local; Trusted_Connection=True;MultipleActiveResultSets=true\"<\/code><\/pre>\n<p>  \u0423 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e ProjectV13. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0434\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a.<br \/>  DefaultConnection \u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 Habr1_Local<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\"> \"ConnectionStrings\": {         \"Habr1_Local\": \"Server=(localdb)\\\\ProjectsV13;Database=Habr1_Local;Trusted_Connection=True;MultipleActiveResultSets=true\"     },<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b Startup.cs \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0430\u043c DefaultConnection \u043d\u0430 Habr1_Local:<\/p>\n<pre><code class=\"cs\">services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; \toptions.UseSqlServer(Configuration.GetConnectionString(\"DefaultConnection\")));<\/code><\/pre>\n<p>  \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 <\/p>\n<pre><code class=\"cs\">services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; \toptions.UseSqlServer(Configuration.GetConnectionString(\"Habr1_Local\"))); <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Debug, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 Login, \u0432\u0432\u043e\u0434\u0438\u043c \u0442\u0443\u0434\u0430 \u043b\u044e\u0431\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 email (\u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442) \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Login \u2014 \u0438 \u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p3\/u3\/r4\/p3u3r4gkdanievaornpxfxwoous.jpeg\" alt=\"image\"><\/p>\n<p>  \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Apply Migration, \u0436\u0434\u0451\u043c \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0441\u0438\u043d\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0447\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043f\u043e\u0434\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u043a\u0440\u0430\u043d \u043e \u0442\u043e\u043c \u0447\u0442\u043e Login Failed:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fc\/sw\/pc\/fcswpc-tqd0gyuhz70cyefi9uls.jpeg\" alt=\"image\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0438\u0434\u0435\u043d \u0442\u0430\u043a\u043e\u0439 \u044d\u043a\u0440\u0430\u043d, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0451 \u043e\u043a \u2014 \u0440\u0430\u0437 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0448\u0451\u043b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u043b invalid login attempt, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b\u043e, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u043d\u0430\u0448\u043b\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438:<\/b><\/p>\n<div class=\"spoiler_text\">\u042d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0435\u0433\u043e \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f \u0432\u0440\u044f\u0434 \u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e.<br \/>  \u0412\u043e\u0442 \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043d\u0438\u043c\u043e\u043a \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043d\u0438\u043c\u043a\u043e\u0432, \u0438 \u044d\u0442\u0438 \u0441\u043d\u0438\u043c\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0442\u0430\u043a \u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438.<\/p>\n<p>  \u0418\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0448\u044c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0447\u0442\u043e-\u0442\u043e, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c production \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u044b, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u2014 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c migration. \u042d\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u0442 \u044d\u0442\u0430 \u0441\u0438\u043d\u044f\u044f \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0430. \u0411\u0430\u0437\u0430 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0435\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0431\u0430\u0437\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0431\u0430\u0437\u044b.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0438 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. Migrations \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 Git \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0442\u0430\u043a\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 C# \u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u2014 \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c \u0441\u0442\u043e\u0438\u0442 \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0430\u0437\u044b \u2014 Visual Studio \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0435\u0451 \u0441\u043e\u0437\u0434\u0430\u0442\u044c<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/op\/6i\/c_\/op6ic_e4cdoarqotsmz441fkmkc.jpeg\" alt=\"image\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u044b \u043d\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0438\u043b\u0438 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d SQL \u0441\u0435\u0440\u0432\u0435\u0440, \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0435\u0449\u0451, \u0432 \u043e\u0431\u0449\u0435\u043c \u043a\u0430\u043a \u0432 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0435 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0431\u044b\u043b\u0438 \u0432\u0440\u0430\u0447\u0430\u043c\u0438: \u00ab\u0434\u043e\u043a\u0442\u043e\u0440, \u0443 \u043c\u0435\u043d\u044f \u043d\u043e\u0433\u0430 \u0431\u043e\u043b\u0438\u0442\u2026 \u2014 \u043d\u0443 \u043d\u0435 \u0437\u043d\u0430\u044e, \u0443 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043d\u043e\u0433\u0430 \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u043e\u043b\u0438\u0442!\u00bb<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u044f \u0434\u0435\u043b\u0430\u044e \u0435\u0449\u0451 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, appsettings.json \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"json\">\"ConnectionStrings\": {         \"Habr1_Local\": \"Server=(localdb)\\\\ProjectsV13;Database=Habr1_Local;Trusted_Connection=True;MultipleActiveResultSets=true\",         \"Habr1_Test\": \"Server=(localdb)\\\\ProjectsV13;Database=Habr1_Test;Trusted_Connection=True;MultipleActiveResultSets=true\",         \"Habr1_Production\": \"Server=(localdb)\\\\ProjectsV13;Database=Habr1_Production;Trusted_Connection=True;MultipleActiveResultSets=true\"     }, <\/code><\/pre>\n<p>  \u0414\u0435\u043b\u0430\u044e commit \u0438 \u043a\u043b\u0430\u0434\u0443 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043d\u0438\u043c\u043e\u043a:<\/p>\n<p>  <b>Snapshot: Snap_1_DataBases<\/b><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443, Snap_2_Configurations<\/p>\n<p>  <b>\u0446\u0435\u043b\u044c: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/b><\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e, \u0438\u0437 View \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e):<\/p>\n<pre><code class=\"cs\">#if DEBUG \t\t\t\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f DEBUG #else \t\t\t\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f RELEASE (\u043d\u0435 DEBUG \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435) #endif<\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b Startup.cs \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 ConfigureServices \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"cs\">public void ConfigureServices(IServiceCollection services) {  \tString ConnStr = \"\"; #if DEBUG \tConnStr = \"Habr1_Local\"; #else \tConnStr = \"Habr1_Production\"; #endif \tservices.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; \t\toptions.UseSqlServer( \t\t\tConfiguration.GetConnectionString(ConnStr))); \tservices.AddDefaultIdentity&lt;IdentityUser&gt;(options =&gt; options.SignIn.RequireConfirmedAccount = true) \t\t.AddEntityFrameworkStores&lt;ApplicationDbContext&gt;(); \tservices.AddControllersWithViews(); \tservices.AddRazorPages(); } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 Habr1_Local \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 connectionstring \u0431\u0443\u0434\u0435\u0442 \u0438\u043b\u0438 Habr1_Local \u0438\u043b\u0438 Habr1_Production<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0431\u0430\u0437\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/p>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c DEBUG \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043a\u0430\u0435\u043c, \u043b\u043e\u0433\u0438\u043d\u0438\u043c\u0441\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c migration, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u0431\u0430\u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043b\u0430\u0441\u044c (Habr1_Local)<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Release \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u043b\u043e\u0433\u0438\u043d\u0438\u043c\u0441\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c migration, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u0431\u0430\u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043b\u0430\u0441\u044c \u2014 \u0443 \u043d\u0430\u0441 2 \u0431\u0430\u0437\u044b.<\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e!<\/p>\n<p>  <b>Snapshot: Snap_3_HabrDB<\/b><\/p>\n<p>  <b>\u0426\u0435\u043b\u044c: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/b><\/p>\n<p>  \u0417\u0430\u0447\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442?<\/p>\n<p>  \u0423 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/li>\n<li>\u041e\u043d\u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0432 \u043d\u0438\u0445 \u043d\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f<\/li>\n<li>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043b\u0435\u0433\u0447\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u043e\u0439 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 add -&gt; new solution folder, \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e DB.<br \/>  \u041f\u043e\u0442\u043e\u043c \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u2014 add new project -&gt; .net standard, \u043d\u0430\u0437\u0432\u0430\u0442\u044c HabrDB.<br \/>  \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u0430\u043a .net standard 2.0, \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 2.1<br \/>  (\u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u043d \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0443\u0442\u044c, \u043f\u0443\u0441\u0442\u044c \u043b\u0435\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 DB \u0438 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e\u0436\u0435).<\/p>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g4\/kb\/wu\/g4kbwu45mu92my9ucaanuldtuhs.jpeg\" alt=\"image\"><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e ApplicationDBContext \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0432\u043e\u0439? \u041d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c? \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0445 \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u043c. \u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043a \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Entity Framework. \u041c\u044b \u0440\u0430\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043c \u0440\u0430\u0437\u043d\u044b\u0435 schema name: \u043e\u0434\u0438\u043d \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f dbo \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u00abhabr\u00bb.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0440\u0435\u043d\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0446\u0438\u0440\u043a\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e. (\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043a\u043b\u0430\u0434\u0430 \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432)<\/p>\n<p>  \u0418 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0432\u043e\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u044d\u0442\u043e \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u043e \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u044d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u0434\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443).<\/p>\n<p>  \u0414\u0430 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a \u043f\u0440\u043e\u0449\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0440\u0430\u0437\u0443, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0441\u043d\u0438\u043c\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u044d\u0442\u0430\u043f 4.<\/p>\n<p>  <b>\u0426\u0435\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u0442\u0430\u043a\u0438\u0435:<\/b><\/p>\n<ul>\n<li>\u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e<\/li>\n<li>\u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 Srartup.cs<\/li>\n<li>\u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 LoginPartial \u0438 ViewImports<\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 Migration \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0432 \u043d\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435<\/li>\n<\/ul>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u043a\u043b\u0430\u0441\u0441 ApplicationDBContext \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 WebApp \u0432 HabrDB.<\/p>\n<p>  \u041e\u043d \u043d\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0438\u0437 WebApp, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 HabrDB \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u043c\u0443 namespace \u043d\u0430 HabrDB, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0443\u0447\u0430 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  \u0414\u0430, \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0445 \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c.<\/p>\n<p>  \u0427\u0435\u0440\u0435\u0437 nuget \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 HabrDB \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Microsoft.AspNetCore.Identity.EntityFrameworkCore.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wj\/-d\/q4\/wj-dq4ldm5nx32fs9hvzdiya5ys.jpeg\" alt=\"image\"><\/p>\n<p>  \u041a\u043b\u0438\u043a\u0430\u0435\u043c \u043d\u0430 \u043b\u0430\u043c\u043f\u043e\u0447\u043a\u0443 \u0438 \u043e\u043d\u0430 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 <s>\u0441\u0438\u043b<\/s> \u0432\u0435\u0440\u0441\u0438\u0439.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b SecurityDBContext (\u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0442\u043e\u0436\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c) \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">using System; using System.Collections.Generic; using System.Text; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;  namespace HabrDB { \tpublic class SecurityDBContext : IdentityDbContext \t{ \t\tpublic SecurityDBContext(DbContextOptions&lt;SecurityDBContext&gt; options) \t\t\t: base(options) \t\t{ \t\t} \t} }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 <s>\u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u043b\u044c\u043d\u0438\u043a\u043e\u043c<\/s> \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0443 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2014 \u043c\u044b \u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u043b\u0438 ApplicationDBContext \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u043d\u0430 SecurityDBContext. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 ApplicationDBContext \u0432\u043e \u0432\u0441\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 SecurityDBContext.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 references \u0438\u0437 WebApp \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0436\u0451\u043b\u0442\u044b\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u042f \u043e\u0447\u0438\u0441\u0442\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442 (build -&gt; clean solution), \u0437\u0430\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0443\u0434\u0430\u043b\u0438\u043b \u0432\u0441\u0435 Debug, Release, Obj \u0438 Bin \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043d\u043e\u0432\u043e, \u043e\u043d \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430\u043b \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u043b \u0438\u0445, \u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u0447\u043a\u0438 \u0438\u0441\u0447\u0435\u0437\u043b\u0438 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0451 \u043e\u043a.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Data \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 WebApp, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432 \u043e\u043a\u043d\u0435 SQL Server Object Explorer \u043d\u0430\u0448\u0438 \u0431\u0430\u0437\u044b (Habr1_Local \u0438 Habr1_Production) \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u2014 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c migration \u0432\u044b\u0434\u0430\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z_\/ex\/ca\/z_excar1pqk18n8pdmyvf3eobog.jpeg\" alt=\"image\"><\/p>\n<p>  \u0412\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u043f\u0430\u043f\u043a\u0443 Data \u0433\u0434\u0435 \u0431\u044b\u043b\u0438 \u0432\u0441\u0435 migrations \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u041d\u043e \u044d\u0442\u043e \u0436\u0435 \u0431\u044b\u043b\u043e \u0442\u0430\u043a \u043a\u0440\u0443\u0442\u043e?! \u0417\u0430\u0447\u0435\u043c?! \u0417\u0430\u0442\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 HabrDB: <br \/>  ApplicationUser.cs<\/p>\n<p>  \u041d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u0442 IdentityUser<\/p>\n<pre><code class=\"cs\">using Microsoft.AspNetCore.Identity; using System; using System.Collections.Generic; using System.Text;  namespace HabrDB { \tpublic class ApplicationUser:IdentityUser \t{ \t\tpublic String NickName { get; set; } \t\tpublic DateTime BirthDate { get; set; } \t\tpublic String PassportNumber { get; set; } \t} }<\/code><\/pre>\n<p>  \u0412 \u0444\u0430\u0439\u043b SecurityDBContext \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"cs\">public class SecurityDBContext : IdentityDbContext&lt;ApplicationUser&gt;<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b EntityFramework \u0437\u043d\u0430\u043b \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0431\u0430\u0437\u044b \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 AppllicationUser \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 ConfigureServices \u0432 \u0444\u0430\u0439\u043b\u0435 Startup.cs \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">public void ConfigureServices(IServiceCollection services) {  \tString ConnStr = \"\"; #if DEBUG \tConnStr = \"Habr1_Local\"; #else \tConnStr = \"Habr1_Production\"; #endif  \tservices.AddDbContext&lt;SecurityDBContext&gt;(options =&gt; \t\toptions.UseSqlServer( \t\t\tConfiguration.GetConnectionString(ConnStr))); \tservices.AddDefaultIdentity&lt;ApplicationUser&gt;(options =&gt; options.SignIn.RequireConfirmedAccount = true) \t\t.AddEntityFrameworkStores&lt;SecurityDBContext&gt;(); \tservices.AddControllersWithViews(); \tservices.AddRazorPages(); }<\/code><\/pre>\n<p>  (\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u043c IdentityUser \u043d\u0430 ApplicationUser)<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 _ViewImports.cshtml \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 <\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/users\/using\/\" class=\"user_link\">using<\/a> HabrDB<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0432\u0438\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u0438\u0434\u043e\u0432 \u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/users\/using\/\" class=\"user_link\">using<\/a> HabrDB.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 _LoginPartial.cshtml \u043c\u0435\u043d\u044f\u0435\u043c \u0432\u0441\u0435 IdentityUser \u043d\u0430 ApplicationUser.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/users\/using\/\" class=\"user_link\">using<\/a> Microsoft.AspNetCore.Identity<br \/>  <a href=\"https:\/\/habr.com\/ru\/users\/inject\/\" class=\"user_link\">inject<\/a> SignInManager SignInManager<br \/>  <a href=\"https:\/\/habr.com\/ru\/users\/inject\/\" class=\"user_link\">inject<\/a> UserManager UserManager<\/p>\n<p>  \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043c\u044b \u043d\u0438\u0433\u0434\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>  \u041d\u0430\u0434\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c Package Manager Console, \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 DB\/HabrDB \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u043c\u0443 <\/p>\n<pre><code class=\"cs\">add-migration initial<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/95\/zv\/aj\/95zvaj1nj3d42hnzq2rk_bvncvo.jpeg\" alt=\"image\"><\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 HabrDB \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0430\u043f\u043e\u0447\u043a\u0430 Migrations \u0438 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b\u0438\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u2014 NickName, BirthDate, PassportNumber.<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f (\u043d\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u043e\u043b\u0438 \u0432\u0432\u043e\u0434\u0438\u0442\u044c):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/01\/ib\/0u\/01ib0ufzxz_bds3n2scb5pqgyoi.jpeg\" alt=\"image\"><\/p>\n<p>  \u041c\u043d\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438 \u044f \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u043b\u0441\u044f \u2014 \u0432\u043e\u0442 \u043d\u0430\u0448\u0430 \u0431\u0430\u0437\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qg\/af\/js\/qgafjs_fgtlnj39nlru_bxb9a2a.jpeg\" alt=\"image\"><\/p>\n<p>  C \u044d\u0442\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0432\u0441\u0451<\/p>\n<p>  <b>Snapshot: Snap_4_Security<\/b> \u0433\u043e\u0442\u043e\u0432<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u044f\u0442\u044b\u0439 \u0441\u043d\u0438\u043c\u043e\u043a.<\/p>\n<p>  <b>\u0426\u0435\u043b\u0438:<\/b><\/p>\n<ul>\n<li>\u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 connection string <\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435<\/li>\n<\/ul>\n<p>  \u041a\u043b\u0438\u043a\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0430 \u043f\u0430\u043f\u043e\u0447\u043a\u0435 DB, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u2014 MSTest .net core.<br \/>  \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432 DBTest \u0438 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0435\u043c\u2026<br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/p>\n<p>  \u041a\u0430\u043a \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ConnectionString \u043c\u0430\u043b\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (WebApp), \u043d\u043e \u0438 \u043a\u0430\u043a-\u0442\u043e \u0443\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 Release\/Debug \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438?.. \u041c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, Test \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440?<\/p>\n<p>  \u041d\u0435\u0442, \u044d\u0442\u043e \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0442\u0435\u0440\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u043a\u0430\u043a-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u044b \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0447\u0442\u043e \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u0436\u043c\u0451\u043c \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 Run All Tests \u2014 \u0430 \u0442\u0430\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0431\u0430\u0437\u044b\u2026 \u043d\u0435\u0442, \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u2026<\/p>\n<p>  \u0417\u043d\u0430\u0447\u0438\u0442 \u0431\u0443\u0434\u0435\u043c \u044f\u0432\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442!<\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b HabrDBContext \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430:<\/p>\n<pre><code class=\"cs\">using System; using System.IO; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration;  namespace HabrDB { \tpublic class HabrDBContext:DbContext \t{ \t\tpublic String ConnectionString = \"\"; \t\tpublic IConfigurationRoot Configuration { get; set; } \t\tpublic HabrDBContext CreateTestContext() \t\t{ \t\t\tDirectoryInfo info = new DirectoryInfo(Directory.GetCurrentDirectory()); \t\t\tDirectoryInfo temp = info.Parent.Parent.Parent.Parent; \t\t\tString CurDir = Path.Combine(temp.ToString(), \"WebApp\"); \t\t\tString ConnStr = \"Habr1_Test\"; \t\t\tConfiguration = new ConfigurationBuilder().SetBasePath(CurDir).AddJsonFile(\"appsettings.json\").Build(); \t\t\tvar builder = new DbContextOptionsBuilder&lt;HabrDBContext&gt;(); \t\t\tvar connectionString = Configuration.GetConnectionString(ConnStr); \t\t\tbuilder.UseSqlServer(connectionString); \t\t\tConnectionString = connectionString; \t\t\treturn this; \t\t} \t} }<\/code><\/pre>\n<p>  \u0427\u0435\u0440\u0435\u0437 Nuget \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"plaintext\">Microsoft.AspNetCore.Identity.EntityFrameworkCore Microsoft.EntityFrameworkCore Microsoft.EntityFrameworkCore.SqlServer Microsoft.Extensions.Configuration.FileExtensions Microsoft.Extensions.Configuration.Json<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 CreateTestContext \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e Connection String \u0441 \u0438\u043c\u0435\u043d\u0435\u043c Habr1_Test. \u0412\u0437\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 reference \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430, \u043c\u044b \u043f\u0440\u043e\u0441\u0438\u043c builder \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u0438 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e connectionString, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0433\u0434\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0432\u0435\u0440\u0445 \u0434\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0443\u0442\u044c \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 WebApp, \u043f\u0440\u043e\u0441\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b appsettings.json \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043d\u0430\u0448\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e. \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0440\u0451\u043c connectionString \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0451 (\u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c).<\/p>\n<p>  \u0412 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, DLL \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041d\u0430\u043c \u043f\u043e\u043a\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430.<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a?<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 ConnectionString \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c \u0431\u0430\u0437\u0443, \u043c\u043e\u0436\u043d\u043e \u0432 \u0431\u0430\u0437\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 ConnectionString. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u0430 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0432\u0435\u0449\u044c: \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0410 \u044f \u043f\u043e \u0441\u0435\u0431\u0435 \u0437\u043d\u0430\u044e \u0447\u0442\u043e \u0433\u043e\u043b\u043e\u0432\u0430 \u0443 \u043c\u0435\u043d\u044f \u0434\u044b\u0440\u044f\u0432\u0430\u044f \u0438 \u044f \u043c\u043e\u0433\u0443 \u0437\u0430\u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438 \u0447\u0442\u043e\u0431\u044b \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u044f \u0434\u0435\u043b\u0430\u044e \u0442\u0430\u043a. \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b appsettings.json \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c.<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 HabrDB \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0430\u043f\u043a\u0443 DBClasses, \u0442\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 code first, \u0435\u0441\u043b\u0438 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u043d\u0435 \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u0435\u0439.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"cs\">using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text;  namespace HabrDB.DBClasses { \t[Table(\"Phones\", Schema =\"Habr\")] \tpublic class Phone \t{ \t\t[Key] \t\tpublic int Id { get; set; } \t\tpublic String Model { get; set; } \t\tpublic DateTime DayZero { get; set; } \t} }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b, \u043f\u0443\u0441\u0442\u044c \u043c\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u00ab\u0442\u0435\u043b\u0435\u0444\u043e\u043d\u00bb \u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0432\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u2014 \u00ab\u0442\u0435\u043b\u0435\u0444\u043e\u043d\u044b\u00bb. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 Table \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043c\u043e\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c namespace \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432 \u0431\u0430\u0437\u0435 (\u0432 SQL \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Schema).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0449\u0451 \u0432\u043e\u043f\u0440\u043e\u0441 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0438: \u0432\u043e\u0442 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043a\u0443\u0447\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0451 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 \u043e\u0434\u043d\u0443 \u043a\u0443\u0447\u0443 \u2014 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c partial \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u043e\u0432\u043e partial \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u043e\u0432\u0430 class \u0432 \u0444\u0430\u0439\u043b\u0435 HabrDBContext.cs \u2014 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public partial class HabrDBContext:DbContext<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043f\u0438\u044e \u0444\u0430\u0439\u043b\u0430 HabrDBContext.cs \u2014 \u043f\u0440\u043e\u043e\u0441\u0442\u043e CTRL+\u0421 \u2014 CTRL+V \u043d\u0430 \u0444\u0430\u0439\u043b\u0435, \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f \u0435\u0433\u043e \u043a\u043e\u043f\u0438\u044f, \u043c\u0435\u043d\u044f\u0435\u043c \u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438\u043c\u044f \u043d\u0430 HabrDBContext_Infrastructure.cs, \u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0430 HabrDBContext_Data.cs<\/p>\n<p>  \u0412 \u043d\u043e\u0432\u043e\u043c \u043f\u0438\u0448\u0435\u043c: <\/p>\n<pre><code class=\"cs\">using HabrDB.DBClasses; using Microsoft.EntityFrameworkCore;  namespace HabrDB { \tpublic partial class HabrDBContext:DbContext \t{ \t\tpublic DbSet&lt;Phone&gt; Phones { get; set; } \t} }<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u2014 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0441 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u0424\u0430\u0439\u043b\u044b \u0440\u0430\u0437\u043d\u044b\u0435, \u0430 \u043a\u043b\u0430\u0441\u0441 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u2014 \u0441\u0440\u0435\u0434\u0430 \u0435\u0433\u043e \u0441\u0430\u043c\u0430 \u0441\u043e\u0431\u0435\u0440\u0451\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u041d\u0443, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c!<\/p>\n<p>  \u0417\u0430\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u0434 \u0432 \u043d\u0430\u0448\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430:<\/p>\n<pre><code class=\"cs\">using HabrDB; using HabrDB.DBClasses; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq;  namespace DBTest { \t[TestClass] \tpublic class DBTest \t{ \t\t[TestMethod] \t\tpublic void TestMethod1() \t\t{ \t\t\tString PhoneName = \"Nokia\"; \t\t\tDateTime now = DateTime.Now;  \t\t\tHabrDBContext db = new HabrDBContext().CreateTestContext(); \t\t\tdb.Database.EnsureCreated();  \t\t\tList&lt;Phone&gt; Phones = db.Phones.ToList(); \t\t\tAssert.AreEqual(0, Phones.Count);  \t\t\tPhone ph = new Phone(); \t\t\tph.Model = PhoneName; \t\t\tph.DayZero = now;  \t\t\tdb.Phones.Add(ph); \t\t\tdb.SaveChanges();  \t\t\tPhone ph1 = db.Phones.Single(); \t\t\tAssert.AreEqual(PhoneName, ph1.Model); \t\t\tAssert.AreEqual(now, ph1.DayZero); \t\t} \t} } <\/code><\/pre>\n<p>  \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 play \u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 Test Explorer (\u0438\u043b\u0438 Test -&gt; Run All Tests) \u0438\u2026<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9w\/qe\/68\/9wqe686vdpg6jet-epu30oakdou.jpeg\" alt=\"image\"><\/p>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430! \u0432\u043e\u0442 \u0442\u0435 \u043d\u0430.<\/p>\n<p>  \u0427\u0438\u0442\u0430\u0435\u043c \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0438\u0448\u0443\u0442:<\/p>\n<pre><code class=\"plaintext\">Message:      Test method DBTest.DBTest.TestMethod1 threw exception:      System.InvalidOperationException: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions&lt;TContext&gt; object in its constructor and passes it to the base constructor for DbContext.<\/code><\/pre>\n<p>  \u041a\u0430\u043a\u0430\u044f-\u0442\u043e \u043b\u0430\u0431\u0443\u0434\u0430 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c\u2026<br \/>  \u041b\u0430\u0434\u043d\u043e, \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0443\u0433\u0430\u0434!<\/p>\n<p>  \u041d\u0435 \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c \u043b\u0438 \u043d\u0430\u043c \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0444\u0430\u0439\u043b HabrDBContext_Infrastructure.cs? \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c!<\/p>\n<pre><code class=\"cs\">protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { \tString ConnStr = \"\"; \tif (Configuration == null) \t{ #if DEBUG  \t\tConnStr = \"Habr1_Local\"; #else \t\tConnStr= \"Habr1_Production\"; #endif  \t\tConfiguration = new ConfigurationBuilder() \t\t\t.SetBasePath(Directory.GetCurrentDirectory()) \t\t\t.AddJsonFile(\"appsettings.json\").Build(); \t\tConnectionString = Configuration.GetConnectionString(ConnStr); \t}  \toptionsBuilder.UseSqlServer(ConnectionString); }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u2026<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u0432\u0435\u0437\u043b\u043e!!!<br \/>  \u0421\u043e\u0437\u0434\u0430\u043b\u0430\u0441\u044c \u043d\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u0438 \u0432 \u043d\u0435\u0439 \u2014 \u043d\u0430\u0448\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/an\/cv\/1a\/ancv1ahppxwymetpwayqqwdtlzg.jpeg\" alt=\"image\"><\/p>\n<p>  \u0417\u0430\u0447\u0435\u043c \u0442\u0430\u043a?<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0443 breakpoints \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 OnConfiguring \u0438 CreateTestContext \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 CreateTestContext, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 ConnectionString \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0412\u0441\u0451 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u041e\u041a. \u041d\u043e \u043f\u043e\u0442\u043e\u043c \u043a\u0442\u043e-\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c OnConfiguring\u2026 \u043a\u0442\u043e \u0436\u0435 \u044d\u0442\u043e? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c call stack \u2014 \u0434\u0430 \u044d\u0442\u043e \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 db.Database.EnsureCreated() \u0438\u0437 \u0442\u0435\u0441\u0442\u0430! \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u0430\u0437\u044b \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u0443 \u043d\u0430\u0441 \u0435\u0449\u0451 \u043d\u0435\u0442 \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0435\u0451 \u043c\u0435\u0442\u043e\u0434 EnsureCreated. \u041d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 EnsureCreated. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u043d\u0435 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0430 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440) \u0442\u043e \u0432\u0441\u044f\u043a\u0438\u0435 middlware, DI, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0437\u0430\u043a\u043e\u0432\u044b\u0440\u0438\u0441\u0442\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u0436\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432\u0441\u0451 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u2014 \u043a\u0442\u043e \u0431\u044b \u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443, \u0435\u0441\u043b\u0438 \u043e\u043d \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c OnConfiguring \u2014 \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c. \u041c\u044b \u0432\u0441\u0451 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u0435\u0449\u0451 \u0440\u0430\u0437 \u2014 \u0438 \u2026<br \/>  \u041e\u043f\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430? <br \/>  \u0411\u0430\u0437\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u0441\u0442\u044c\u2026 \u0447\u0442\u043e \u043d\u0435 \u0442\u0430\u043a?<br \/>  \u0411\u0430\u0437\u0430 \u044d\u0442\u043e \u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442\u2026 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0441\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435. \u041a\u0430\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u0438 \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b? \u041a\u0430\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b?<\/p>\n<p>  <b>Snapshot: Snap_5_ContextCrafting \u0433\u043e\u0442\u043e\u0432<\/b><\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c DAL \u2014 Data Access Layer.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043f\u0438\u044e \u0444\u0430\u0439\u043b\u0430 HabrDBContext_Data.cs, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0451 HabrDBContext_DAL.cs<br \/>  \u0432 \u043d\u0435\u0439 \u043d\u0430\u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"cs\">using HabrDB.DBClasses; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Threading.Tasks;  namespace HabrDB { \tpublic partial class HabrDBContext:DbContext \t{ \t\tpublic async Task&lt;int&gt; AddPhone(Phone ph) \t\t{ \t\t\tthis.Phones.Add(ph); \t\t\tint res = await this.SaveChangesAsync(); \t\t\treturn res; \t\t}  \t\tpublic async Task&lt;List&lt;Phone&gt;&gt; GetAllPhones() \t\t{ \t\t\tList&lt;Phone&gt; phones = await this.Phones.ToListAsync(); \t\t\treturn phones; \t\t} \t} } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u2014 \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u043d\u0430\u0448\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041c\u043d\u0435 \u0431\u044b \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0435\u0441\u043b\u0438 \u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u044e \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435, \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0433\u0434\u0435 \u044f \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u2014 Data Access Layer. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0431\u0430\u0437\u043e\u0439 \u0438 MVC \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438 \u0441\u0430\u0439\u0442\u0430 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432. \u0418 \u2014 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435? \u2014 \u0443 \u043d\u0430\u0441 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u2014 \u043e\u043d\u0438 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u044e\u0442 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u043d\u0438\u0437\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c\u044e.<br \/>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u2014 \u0438 \u0437\u0430 \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0435\u0451 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c!<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430!<\/p>\n<p>  \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<br \/>  \u041f\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0451 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 DI \u0432 startup.cs, \u043d\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u0430\u043a<\/p>\n<p>  \u041d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">[TestMethod] public void AddPhone_Test() { \tString PhoneName = \"Nokia\"; \tDateTime now = DateTime.Now;  \tHabrDBContext db = new HabrDBContext().CreateTestContext(); \tdb.Database.EnsureCreated();  \tList&lt;Phone&gt; Phones = db.GetAllPhones().Result; \tAssert.AreEqual(0, Phones.Count);  \tPhone ph = new Phone(); \tph.Model = PhoneName; \tph.DayZero = now;  \tdb.AddPhone(ph);  \tPhone ph1 = db.Phones.Single(); \tAssert.AreEqual(PhoneName, ph1.Model); \tAssert.AreEqual(now, ph1.DayZero); } <\/code><\/pre>\n<p>  \u0423\u0434\u0430\u043b\u0438\u043c \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u043c, \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u2014 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<br \/>  \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443 \u0432\u0430\u0441 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u043e\u0433\u0430. \u0423 \u043c\u0435\u043d\u044f \u0432\u0441\u0451 \u0437\u0435\u043b\u0451\u043d\u0435\u043d\u044c\u043a\u043e\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kc\/vz\/ea\/kcvzeaiyug4owclncwblblpqoaw.jpeg\" alt=\"image\"><\/p>\n<p>  \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 db.GetAllPhones().Result? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0444\u0443\u043a\u0446\u0438\u0438 DAL \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435. \u041d\u043e \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0451\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c await. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0442\u0430\u043b\u0430 async Task \u2014 \u0438\u043d\u0430\u0447\u0435 \u0442\u0435\u0441\u0442 \u0432\u043e\u0431\u0449\u0435 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f, \u0438 \u0432\u0435\u0437\u0434\u0435 \u0433\u0434\u0435 \u0432\u044b\u0437\u043e\u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u2014 \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u043d\u0443\u0436\u0435\u043d await<\/p>\n<pre><code class=\"cs\">[TestMethod] public async Task AddPhone_Test() { \tString PhoneName = \"Nokia\"; \tDateTime now = DateTime.Now;  \tHabrDBContext db = new HabrDBContext().CreateTestContext(); \tdb.Database.EnsureCreated();  \tList&lt;Phone&gt; Phones = await db.GetAllPhones(); \tAssert.AreEqual(0, Phones.Count);  \tPhone ph = new Phone(); \tph.Model = PhoneName; \tph.DayZero = now;  \tawait db.AddPhone(ph);  \tPhone ph1 = db.Phones.Single(); \tAssert.AreEqual(PhoneName, ph1.Model); \tAssert.AreEqual(now, ph1.DayZero); } <\/code><\/pre>\n<p>  \u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438 Task \u0430 \u043d\u0435 void \u2014 \u0438\u043d\u0430\u0447\u0435 \u0442\u0435\u0441\u0442\u044b \u0438\u043b\u0438 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u044f\u0442\u0441\u044f \u0438\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0436\u0434\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0439\u0434\u0443\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  \u0422\u0430\u043a, \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. <\/p>\n<p>  <b>Snapshot: Snap_6_Dal<\/b><\/p>\n<p>  \u0410 \u0447\u0442\u043e, \u0442\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e? \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435\u0442!<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0438\u0437 \u0431\u0430\u0437\u044b\u2026<\/p>\n<p>  \u041a\u0440\u0443\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c db.Database.EnsureDeleted\u2026 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e!<\/p>\n<p>  \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u2026 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0430\u0437\u044b \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u043f\u0430\u0440\u043e\u043b\u044f\u043c\u0438. \u0410 \u0435\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u2014 \u0447\u0435\u0440\u0435\u0437 SQL Management Studio, \u0430 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0438\u0437 db.Database.EnsureDeleted \u043e\u043d\u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u0430\u0440\u043e\u043b\u044f\u043c\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u0430\u043c\u0438, \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0451 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437, \u0442\u043e \u043a \u0431\u0430\u0437\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<p>  \u042d\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0438 \u0442\u0430\u043a \u0442\u0435\u0441\u0442\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438, \u0438 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u0441\u0435\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.<\/p>\n<p>  \u0418 \u0442\u0440\u0435\u0442\u044c\u0435: \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0435\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u043c\u0438.<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e db.Database.EnsureDeleted, \u043d\u0430\u0436\u0430\u0442\u044c \u0441\u043a\u043e\u0431\u043e\u0447\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442, \u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043d\u0435\u0451 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438\u2026<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uh\/by\/ti\/uhbytib40xtjnbwfapd26iqtrus.jpeg\" alt=\"image\"><\/p>\n<p>  \u0414\u0430, \u043d\u0435 \u0433\u0443\u0441\u0442\u043e\u2026<br \/>  \u043d\u0443 \u043b\u0430\u0434\u043d\u043e, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u044e.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, (\u0432 \u0441\u0430\u043c\u043e\u043c solution) \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439, add -&gt; .net standard C#, \u0438 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e Extensions. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b 2.1 \u0432\u0435\u0440\u0441\u0438\u0438. <\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 Extensions \u0432 DBContextExtensions.cs \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">using Microsoft.EntityFrameworkCore; using System; using System.Linq; using Microsoft.EntityFrameworkCore.Infrastructure;  namespace Extensions { \tpublic static class DBContextExtensions \t{ \t\tpublic static int EnsureDeleted&lt;TEntity&gt;(this DatabaseFacade db, DbSet&lt;TEntity&gt; set) where TEntity : class \t\t{ \t\t\tTableDescription Table = GetTableName(set); \t\t\tint res = 0; \t\t\ttry \t\t\t{ \t\t\t\tres = db.ExecuteSqlRaw($\"DROP TABLE [{Table.Schema}].[{Table.TableName}];\"); \t\t\t} \t\t\tcatch (Exception) \t\t\t{  \t\t\t} \t\t\treturn res; \t\t}  \t\tpublic static TableDescription GetTableName&lt;T&gt;(this DbSet&lt;T&gt; dbSet) where T : class \t\t{ \t\t\tvar dbContext = dbSet.GetDbContext();  \t\t\tvar model = dbContext.Model; \t\t\tvar entityTypes = model.GetEntityTypes(); \t\t\tvar entityType = entityTypes.First(t =&gt; t.ClrType == typeof(T)); \t\t\tvar tableNameAnnotation = entityType.GetAnnotation(\"Relational:TableName\"); \t\t\tvar tableSchemaAnnotation = entityType.GetAnnotation(\"Relational:Schema\"); \t\t\tvar tableName = tableNameAnnotation.Value.ToString(); \t\t\tvar schemaName = tableSchemaAnnotation.Value.ToString(); \t\t\treturn new TableDescription { Schema = schemaName, TableName = tableName }; \t\t}  \t\tpublic static DbContext GetDbContext&lt;T&gt;(this DbSet&lt;T&gt; dbSet) where T : class \t\t{ \t\t\tvar infrastructure = dbSet as IInfrastructure&lt;IServiceProvider&gt;; \t\t\tvar serviceProvider = infrastructure.Instance; \t\t\tvar currentDbContext = serviceProvider.GetService(typeof(ICurrentDbContext)) as ICurrentDbContext; \t\t\treturn currentDbContext.Context; \t\t} \t}  \tpublic class TableDescription \t{ \t\tpublic String Schema { get; set; } \t\tpublic String TableName { get; set; } \t} } <\/code><\/pre>\n<p>  \u0418\u0437 Nuget \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c Microsoft.EntityFrameworkCore<br \/>  \u0418 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0430\u043a\u0435\u0442 \u2014 Microsoft.EntityFrameworkCore.Relational<\/p>\n<p>  Extensions \u2014 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u2014 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e this \u043f\u0435\u0440\u0435\u0434 \u0442\u0438\u043f\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/p>\n<pre><code class=\"cs\">public static int EnsureDeleted&lt;TEntity&gt;(this DatabaseFacade db, DbSet&lt;TEntity&gt; set) where TEntity : class<\/code><\/pre>\n<p>  \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 DatabaseFacade \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 EnsureDeleted \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e\u0439 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438! where TEntity: class \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e TEntity \u0438\u043c\u0435\u0435\u0442 constraint \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0431\u043e\u0431\u0449\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0430 \u0447\u0435\u043c-\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0432\u0438\u0436\u0443 \u0432\u0430\u0448 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e? <\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GetTableName, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 EnsureDeleted, \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435. <br \/>  \u0410 \u0437\u0430\u0447\u0435\u043c \u0435\u0439 \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435?<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GetDbContext, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 GetTableName, \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u2026<\/p>\n<p>  \u0410 \u0435\u0439 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435???!!! \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b \u043d\u0430 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u043d\u0430\u0445 \u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u0430\u0432\u044b\u2026<\/p>\n<p>  DbSet, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c GetDbContext \u0432 \u0441\u0442\u0440\u043e\u043a\u0435<\/p>\n<pre><code class=\"cs\">Public static DbContext GetDbContext&lt;T&gt;(this DbSet&lt;T&gt; dbSet) where T : class<\/code><\/pre>\n<p>  , \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0447\u0442\u043e\u0431\u044b T \u0431\u044b\u043b \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u0430 class \u043a\u0430\u043a \u0440\u0430\u0437 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445\u2026<\/p>\n<p>  \u0422\u0430\u043a \u0432\u043e\u0442, \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u2014 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u2014 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434 EnsureDeleted \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043b\u043e\u0445\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c. \u042f \u0445\u043e\u0447\u0443 \u0447\u0442\u043e\u0431\u044b \u043c\u043d\u0435 DBContext \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c, \u0438 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u043e\u043d \u0443\u0436\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043f\u043e\u0442\u043e\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u0435\u0440\u0451\u0442 \u043c\u043e\u0434\u0435\u043b\u044c, \u0438\u0437 \u043d\u0435\u0451 \u0442\u0438\u043f\u044b, \u043f\u043e\u0442\u043e\u043c \u0441\u0440\u0435\u0434\u0438 \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0449\u0435\u0442 \u0442\u043e\u0442 \u0443 \u043a\u043e\u0433\u043e \u0442\u0438\u043f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043a\u0430\u043a \u0443 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (\u044d\u0442\u043e \u0443\u0436\u0435 \u0432 GetTableName), \u043f\u043e\u0442\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0440\u0451\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0441\u0445\u0435\u043c\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u044d\u0442\u043e \u0443\u0436\u0435 \u0432 EnsureDeleted \u0438 \u0442\u0430\u043c \u2014 \u0432\u043e\u0442 \u0431\u043b\u0438\u043d! \u043e\u043f\u044f\u0442\u044c \u043d\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 removetable \u0438\u043b\u0438 \u0447\u0435\u0433\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 \u0442\u043e\u0433\u043e, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e SQL \u0441\u044b\u0440\u043d\u0438\u043a\u0438\u2026 \u043d\u0443 \u0445\u043e\u0440\u043e\u0448\u043e \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c!<\/p>\n<p>  \u0410 exception \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 EnsureDeleted \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446, \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0442\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0438 \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0442\u0435\u0441\u0442\u044b \u043c\u0435\u0442\u043e\u0434 (\u0432 \u043a\u043e\u043d\u0435\u0446) <\/p>\n<pre><code class=\"cs\">[TestMethod] public void DeleteTable_Test() { \tHabrDBContext db = new HabrDBContext().CreateTestContext(); \tdb.Database.EnsureDeleted(db.Phones); }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u044b\u0434\u044b\u0445\u0430\u0435\u043c\u2026<br \/>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0449\u0451 \u0440\u0430\u0437 \u2014 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>  <b>Snapshot: Snap_7_Extensions<\/b><\/p>\n<p>  \u043a \u043d\u043e\u0432\u044b\u043c <s>\u0433\u0435\u043c\u043e\u0440\u043e\u044f\u043c <\/s>\u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043c<\/p>\n<p>  \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 HabrDBContext \u0443 \u043d\u0430\u0441 \u043d\u0435 \u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u044b\u0439 (\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435). (\u041d\u0443 \u0434\u0430, \u043a\u0430\u0433\u0431\u044d \u0438\u0434\u0435\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438. \u0410 \u043c\u044b \u044d\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u044c! \u0425\u043e\u0440\u043e\u0448\u043e \u0447\u0442\u043e \u043c\u0438\u043b\u0438\u0446\u0438\u044f \u043d\u0435 \u0432\u0438\u0434\u0438\u0442&#8230;)<\/p>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e, \u0438 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0435\u0436\u0434\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b \u043e\u0431\u0449\u0438\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041d\u0435 \u043c\u043e\u0436\u0435\u043c? \u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e, \u0431\u0443\u0434\u0435\u043c \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043a\u043d\u0446\u0438\u0438 \u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cs\">HabrDBContext db = new HabrDBContext().CreateTestContext(); db.Database.EnsureCreated();<\/code><\/pre>\n<p>  \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c<\/p>\n<pre><code class=\"cs\">HabrDBContext db = new HabrDBContext().CreateTestContext(); db.Database.EnsureDeleted(db.Phones);<\/code><\/pre>\n<p>  \u0438 \u0435\u0449\u0451 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u2026<\/p>\n<p>  \u041d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u2026 \u0440\u0430\u0437 \u043c\u044b \u043e\u0434\u0435\u0432\u0430\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0438\u0434\u0436\u0443 \u2014 \u043f\u043e\u0438\u0449\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435!<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b.<\/p>\n<p>  \u042d\u0442\u043e \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0442\u0451\u0436 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0447\u0435\u0440\u0442\u0435\u0436\u0443, \u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0447\u043b\u0435\u043d \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0447\u043b\u0435\u043d \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0441\u0443\u0449 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e \u0447\u0435\u0440\u0442\u0435\u0436\u0443, \u0430 \u0441\u0430\u043c\u043e\u043c\u0443 \u044d\u0442\u043e\u043c\u0443 \u0447\u0435\u0440\u0442\u0435\u0436\u0443.<\/p>\n<p>  \u0412\u043e\u0442 \u044d\u0442\u043e \u0443\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u2026<br \/>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c!<\/p>\n<p>  \u041d\u0430\u0448 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f DBTest, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 db<\/p>\n<pre><code class=\"cs\">using HabrDB; using HabrDB.DBClasses; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Extensions;  namespace DBTest { \t[TestClass] \tpublic class DBTest \t{ \t\tpublic static HabrDBContext db;  \t\t[TestMethod] \t\tpublic void AA0_init() \t\t{ \t\t\tdb = new HabrDBContext().CreateTestContext(); \t\t\tdb.Database.EnsureCreated(); \t\t}  \t\t[TestMethod] \t\tpublic async Task AddPhone_Test() \t\t{ \t\t\tString PhoneName = \"Nokia\"; \t\t\tDateTime now = DateTime.Now;  \t\t\tList&lt;Phone&gt; Phones = await db.GetAllPhones(); \t\t\tAssert.AreEqual(0, Phones.Count);  \t\t\tPhone ph = new Phone(); \t\t\tph.Model = PhoneName; \t\t\tph.DayZero = now;  \t\t\tawait db.AddPhone(ph);  \t\t\tPhone ph1 = db.Phones.Single(); \t\t\tAssert.AreEqual(PhoneName, ph1.Model); \t\t\tAssert.AreEqual(now, ph1.DayZero); \t\t}  \t\t[TestMethod] \t\tpublic void DeleteTable_Test() \t\t{ \t\t\tdb.Database.EnsureDeleted(db.Phones); \t\t} \t} } <\/code><\/pre>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>  \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u0442\u0443\u043f\u043e \u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a \u043c\u0435\u0442\u043e\u0434\u044b.<br \/>  \u0415\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435!<br \/>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b!<br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c DBTestBase, \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043e\u0442 \u043d\u0435\u0433\u043e \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 DBTest.<br \/>  \u0418\u0437 DBTest \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0451, \u043a\u0440\u043e\u043c\u0435:<\/p>\n<pre><code class=\"cs\">using HabrDB; using HabrDB.DBClasses; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Extensions;  namespace DBTest { \t[TestClass] \tpublic class DBTest:DBTestBase \t{ \t\t[TestMethod] \t\tpublic async Task AddPhone_Test() \t\t{ \t\t\tString PhoneName = \"Nokia\"; \t\t\tDateTime now = DateTime.Now;  \t\t\tList&lt;Phone&gt; Phones = await db.GetAllPhones(); \t\t\tAssert.AreEqual(0, Phones.Count);  \t\t\tPhone ph = new Phone(); \t\t\tph.Model = PhoneName; \t\t\tph.DayZero = now;  \t\t\tawait db.AddPhone(ph);  \t\t\tPhone ph1 = db.Phones.Single(); \t\t\tAssert.AreEqual(PhoneName, ph1.Model); \t\t\tAssert.AreEqual(now, ph1.DayZero); \t\t}  \t\t[ClassCleanup] \t\tpublic static void DeleteTable() \t\t{ \t\t\tdb.Database.EnsureDeleted(db.Phones); \t\t} \t} } <\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 DBTestBase:<\/p>\n<pre><code class=\"cs\">using HabrDB; using Microsoft.VisualStudio.TestTools.UnitTesting;   namespace DBTest { \t[TestClass] \tpublic class DBTestBase \t{ \t\tpublic static HabrDBContext db{ get; set; }  \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Executes once before the test run. (Optional) \t\t\/\/\/ &lt;\/summary&gt; \t\t\/\/\/ &lt;param name=\"context\"&gt;&lt;\/param&gt; \t\t[AssemblyInitialize] \t\tpublic static void AssemblyInit(TestContext context) \t\t{ \t\t\tdb = new HabrDBContext().CreateTestContext(); \t\t\tdb.Database.EnsureCreated(); \t\t} \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Executes before this class creation \t\t\/\/\/ &lt;\/summary&gt; \t\t\/\/\/ &lt;param name=\"context\"&gt;&lt;\/param&gt; \t\t[ClassInitialize] \t\tpublic static void TestFixtureSetup(TestContext context) \t\t{  \t\t}  \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Executes Before each test  \t\t\/\/\/ &lt;\/summary&gt; \t\t[TestInitialize] \t\tpublic void Setup() \t\t{  \t\t}  \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Executes once after the test run \t\t\/\/\/ &lt;\/summary&gt; \t\t[AssemblyCleanup] \t\tpublic static void AssemblyCleanup() \t\t{  \t\t}  \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Runs once after all tests in this class are executed. \t\t\/\/\/ Not guaranteed that it executes instantly after all tests from the class. \t\t\/\/\/ &lt;\/summary&gt; \t\t[ClassCleanup] \t\tpublic static void TestFixtureTearDown() \t\t{  \t\t}  \t\t\/\/\/ &lt;summary&gt; \t\t\/\/\/ Executes after each test \t\t\/\/\/ &lt;\/summary&gt; \t\t[TestCleanup] \t\tpublic void TearDown() \t\t{ \t\t\t\/\/db.Database.EnsureDeleted();\/\/don`t call! delete database instead of tables! \t\t} \t} }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e! \u041d\u0430\u0448\u0430 \u0431\u0430\u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 DBTestBase, \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u0441\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043e\u0442 \u043d\u0435\u0451. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c [ClassCleanup] \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u00abcleaner\u00bb \u0442\u0435\u0441\u0442\u0430 \u2014 \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0434\u0430\u043b\u0438\u0442 \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u0442\u0435\u0441\u0442\u0435, \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044f \u0441\u0430\u043c\u0443 \u0431\u0430\u0437\u0443.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0438\u0437 \u043c\u0435\u0442\u0440\u0438\u043a, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u043e\u043f\u0438\u0446\u043e\u0442 \u043b\u0435\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u043a\u0438\u0439 \u0440\u043e\u0441\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 DAL \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u043f\u0440\u0438\u0447\u0451\u043c \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043e\u0434\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0433\u0434\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>  \u0415\u0449\u0451 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043b\u0435\u0439\u043b\u0438\u0441\u0442\u044b.<\/p>\n<p>  \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0447\u0438\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).<\/p>\n<p>  \u041f\u043e\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e DAL \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e DAL, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0442\u043e-\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u0447\u0451\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<p>  \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u044d\u0442\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0442\u0430\u043a \u0438 \u043d\u0430\u0434\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c:<\/p>\n<p>  T1_AddPhone_Test,<br \/>  T2_RemovePhone_Test,<br \/>  \u0438 \u0442.\u0434.\u2026<\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0432\u043e\u043b\u043d\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u2014 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u0439!<br \/>  \u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u0432\u043d\u043e \u043f\u043e\u0440\u0430 \u0441\u043f\u0430\u0442\u044c! \u0423 \u043c\u0435\u043d\u044f \u0442\u0430\u043c \u0435\u0449\u0451 \u0434\u0435\u0432\u0447\u0451\u043d\u043a\u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f\u2026<\/p>\n<p>  \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \u0412\u0441\u0435\u043c \u043f\u043e\u043a\u0430!<\/p>\n<p>  git repository \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <a href=\"https:\/\/github.com\/3263927\/Habr_1\" rel=\"nofollow\">https:\/\/github.com\/3263927\/Habr_1<\/a><\/p>\n<p>  \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u043e \u0437\u0430\u043f\u0438\u043b\u044e \u043f\u043e\u0441\u0442 \u043f\u0440\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Identity, Roles, Claims, 3D \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e TypeFilterAttribute (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u0442 \u0438 \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438\u0437 \u0440\u043e\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u044d\u0442\u0443 \u0440\u043e\u043b\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442 \u0437\u0430\u043c\u0443\u0436. \u0410 \u0417\u0410\u041c\u0423\u0416 \u041d\u0415 \u0412\u042b\u0419\u0414\u0415\u0422 \u041f\u041e\u041a\u0410 \u041d\u0415 \u0411\u0423\u0414\u0415\u0422 \u041f\u0420\u041e\u0422\u0415\u0421\u0422\u0418\u0420\u041e\u0412\u0410\u041d! :\/)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u043d\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e, \u044f \u043f\u0440\u043e\u0448\u0451\u043b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ek\/8u\/bl\/ek8ublhenuarw7809onfz2l_nx4.jpeg\" alt=\"image\">  <\/div>\n<\/div>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/481474\/\"> https:\/\/habr.com\/ru\/post\/481474\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481474\/\">\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f<\/h4>\n<p>  \u0423\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u044c \u0432\u0435\u043a\u0430 \u043f\u0440\u0430\u0437\u0434\u043d\u0443\u0435\u043c \u043c\u0438\u043b\u043b\u0435\u043d\u0438\u0443\u043c, \u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0449\u0451 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c\u2026 \u0421\u043b\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0443\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0443 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435\u2026 \u0414\u0430 \u0447\u0435\u0433\u043e \u0443\u0436 \u0442\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u0445, \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043c\u0435\u0440\u0442\u043d\u044b\u043c \u0438 \u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u0441\u043d\u043e\u0432\u0430 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c! \u041a\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u0432\u0449\u0438\u0446\u0443 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u2014 \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u044a\u0435\u0441\u0442\u044c \u0435\u0433\u043e! \u0414\u0430\u0436\u0435 \u0431\u044b\u0432\u0430\u043b\u044b\u0435 \u043e\u0445\u0440\u0430\u043d\u043d\u0438\u043a\u0438 \u044f\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u2014 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0433\u043d\u0430\u0442\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0435. \u0418 \u043d\u0435 \u0434\u043e\u043a\u0430\u0436\u0435\u0448\u044c \u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443\u0436 \u0441\u0430\u043c \u0413\u043e\u0441\u043f\u043e\u0434\u044c \u0411\u043e\u0433 \u043d\u0435 \u0433\u043d\u0443\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TDD \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0412\u0435\u043b\u0438\u043a\u0438\u0439 \u041f\u043e\u0442\u043e\u043f), \u0442\u043e \u043d\u0430\u043c \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0441\u0430\u043c \u0431\u043e\u0433 \u0432\u0435\u043b\u0435\u043b\u2026<\/p>\n<p>  \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0432\u043e\u0434\u043e\u0432 \u0440\u0430\u0441\u0442\u0451\u0442 \u2014 \u043f\u043e\u0447\u0435\u043c\u0443? \u0414\u0430 \u0432\u0441\u0451 \u043f\u043e\u0442\u043e\u043c\u0443 \u0436\u0435! TDD! \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439 \u2014 \u043f\u043e\u0442\u043e\u043c \u0436\u0435\u043d\u0438\u0441\u044c! \u041d\u0435\u0442, \u0434\u043e\u0432\u0435\u0440\u0447\u0438\u0432\u044b\u0435 \u043c\u0443\u0436\u0438\u0447\u043a\u0438 \u0432 \u0440\u0430\u0441\u0445\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044b\u0445 \u0442\u0443\u043b\u0443\u043f\u0430\u0445, \u043f\u0430\u0434\u043a\u0438\u0435 \u043d\u0430 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0441\u0435\u043a\u0441 \u0440\u0435\u043a\u043b\u0430\u043c\u0443, \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043c\u043e\u043b\u043e\u0434\u0443\u044e \u0436\u0435\u043d\u0443 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u2026 <\/p>\n<p>  \u041d\u0443 \u043c\u044b \u0442\u043e \u0441 \u0432\u0430\u043c\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435!<\/p>\n<h4>\u042f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0443\u0437\u043d\u0430\u044e \u043f\u043e \u043f\u043e\u0445\u043e\u0434\u043a\u0435\u2026<\/h4>\n<p>  \u0418 \u0432\u043e\u0442 \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 code first \u0442\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e DAL \u0441\u043b\u043e\u044f \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432 VisualStudio \u0442\u0435\u0441\u0442\u0430\u0445?<\/p>\n<p>  \u0418 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0434\u043b\u044f EntityFramework, \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u043e\u0439 \u043b\u043e\u0432\u043a\u043e\u0441\u0442\u0438 \u0440\u0443\u043a \u043f\u043e\u0434 \u043e\u0434\u0435\u044f\u043b\u043e\u043c \u0438 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441 fake-\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 \u0440\u0430\u0441\u0447\u0435\u0445\u043b\u044f\u0435\u043c VS, \u043e\u0434\u0435\u0432\u0430\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 \u0438 \u0432\u043f\u0435\u0440\u0451\u0434! (\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0435\u0432\u0430\u044e\u0441\u044c \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0434\u0435\u0436\u0434\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tg\/pv\/kw\/tgpvkwgvjzb4zf7tt-navdbcazi.jpeg\" alt=\"image\">  <\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296190","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296190"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296190\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}