{"id":375,"date":"2023-02-03T11:48:09","date_gmt":"2023-02-03T11:48:09","guid":{"rendered":"https:\/\/dijix.com.ua\/blog\/?p=375"},"modified":"2023-02-03T13:30:17","modified_gmt":"2023-02-03T13:30:17","slug":"magazin-na-asp-net-core-mvc-ef-chast-3","status":"publish","type":"post","link":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/","title":{"rendered":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3"},"content":{"rendered":"<p>\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 Entity Framework Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445 \u0443 \u0411\u0414. \u0414\u043b\u044f \u043e\u0437\u043d\u0430\u0439\u043e\u043c\u043b\u0435\u043d\u043d\u044f \u0437 \u0434\u0440\u0443\u0433\u043e\u044e \u0447\u0430\u0441\u0442\u0438\u043d\u043e\u044e, \u043f\u0435\u0440\u0435\u0439\u0434\u0456\u0442\u044c \u0437\u0430 <a href=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-2\/\">\u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f\u043c<\/a>.<\/p>\n<p>\u0423 \u0446\u044c\u043e\u043c\u0443 \u0440\u043e\u0437\u0434\u0456\u043b\u0456 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445 \u0434\u043b\u044f \u0434\u043e\u0434\u0430\u0442\u043a\u0430 GameStore \u0431\u0443\u0434\u0435 \u0440\u043e\u0437\u0448\u0438\u0440\u0435\u043d\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0454\u0434\u0438\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0443 Product. \u0412\u0438 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0435, \u044f\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u0434\u0430\u043d\u0456, \u0437\u0430\u043c\u0456\u043d\u044e\u044e\u0447\u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u0443 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u043e\u043a\u0440\u0435\u043c\u0438\u043c \u043a\u043b\u0430\u0441\u043e\u043c, \u0456 \u0434\u0456\u0437\u043d\u0430\u0454\u0442\u0435\u0441\u044f, \u044f\u043a\u0438\u043c \u0447\u0438\u043d\u043e\u043c \u043e\u0442\u0440\u0438\u043c\u0443\u0432\u0430\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u0434\u0430\u043d\u0438\u0445 \u043f\u0456\u0441\u043b\u044f \u0457\u0445 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f. \u041a\u0440\u0456\u043c \u0442\u043e\u0433\u043e, \u0434\u043e\u0434\u0430\u0454\u0442\u044c\u0441\u044f \u043f\u0456\u0434\u0442\u0440\u0438\u043c\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c \u043f\u043e\u043a\u0443\u043f\u0446\u0456\u0432, \u044f\u043a\u0430 \u0454 \u0432\u0430\u0436\u043b\u0438\u0432\u043e\u044e \u0447\u0430\u0441\u0442\u0438\u043d\u043e\u044e \u0431\u0443\u0434\u044c-\u044f\u043a\u043e\u0433\u043e \u0456\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0443.<\/p>\n<h2>\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3<\/h2>\n<p><a href=\"#steps\">\u041f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u0447\u0456 \u043a\u0440\u043e\u043a\u0438<\/a><\/p>\n<p><a href=\"#addingrelations\">\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u0434\u043e \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445<\/a><\/p>\n<p><a href=\"#creatingrelations\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0442\u043e\u0441\u0443\u043d\u043a\u0456\u0432<\/a><\/p>\n<p><a href=\"#updatecontent\">\u041e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u0442\u0430 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0445\u043e\u0432\u0438\u0449\u0430<\/a><\/p>\n<p><a href=\"#addmigration\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0442\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457<\/a><\/p>\n<p><a href=\"#createcontroller\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430 \u0442\u0430 \u043f\u043e\u0434\u0430\u043d\u043d\u044f<\/a><\/p>\n<p><a href=\"#createdatabase\">\u0417\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044f\u043c\u0438<\/a><\/p>\n<p><a href=\"#createdata\">\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438<\/a><\/p>\n<p><a href=\"#choosecategory\">\u0412\u0438\u0431\u0456\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 \u0434\u043b\u044f \u0442\u043e\u0432\u0430\u0440\u0443<\/a><\/p>\n<p><a href=\"#addingorder\">\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043f\u0456\u0434\u0442\u0440\u0438\u043c\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c<\/a><\/p>\n<p><a href=\"#createrepository\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0456 \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445<\/a><\/p>\n<p><a href=\"#addmigarionanduse\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0442\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457<\/a><\/p>\n<p><a href=\"#addviews\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0456\u0432 \u0456 \u0443\u044f\u0432\u043b\u0435\u043d\u044c<\/a><\/p>\n<p><a href=\"#savingordersdata\">\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445 \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f<\/a><\/p>\n<p><a href=\"#final\">\u041f\u0456\u0434\u0441\u0443\u043c\u043e\u043a<\/a><\/p>\n<h2 id=\"steps\">\u041f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u0447\u0456 \u043a\u0440\u043e\u043a\u0438<\/h2>\n<p>\u0423 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043c\u0438 \u043a\u043e\u043d\u0441\u043e\u043b\u0456\u0434\u0443\u0454\u043c\u043e \u043f\u0440\u043e\u0446\u0435\u0441 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0456 \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 Product \u0432 \u0454\u0434\u0438\u043d\u043e\u043c\u0443 \u043f\u043e\u0434\u0430\u043d\u043d\u0456. \u0423 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0456 \u043e\u0431&#8217;\u0454\u0434\u043d\u0443\u0454\u043c\u043e \u043c\u0435\u0442\u043e\u0434\u0438 \u0434\u0456\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430 Home, \u0449\u043e \u0434\u043e\u0434\u0430\u044e\u0442\u044c \u0430\u0431\u043e \u043e\u043d\u043e\u0432\u043b\u044e\u044e\u0442\u044c \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 Product, \u0456 \u0432\u0438\u0434\u0430\u043b\u044f\u0454\u043c\u043e \u0434\u0456\u0457, \u044f\u043a\u0456 \u0432\u0438\u043a\u043e\u043d\u0443\u0432\u0430\u043b\u0438 \u043c\u0430\u0441\u043e\u0432\u0456 \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f:<\/p>\n<pre class=\"lang:default decode:true \">public class HomeController : Controller\r\n    {\r\n        private readonly IProduct _products;\r\n\r\n        public HomeController(IProduct products)\r\n        {\r\n            _products = products;\r\n        }\r\n        [HttpGet]\r\n        public IActionResult Index()\r\n        {\r\n            return View(_products.GetAllProducts());\r\n        }        \r\n        [HttpGet]\r\n        public IActionResult UpdateProduct(int id)\r\n        {\r\n            return View(id == 0 ? new Product() : _products.GetProduct(id));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult UpdateProduct(Product product)\r\n        {\r\n            if (product.Id == 0)\r\n            {\r\n                _products.AddProduct(product);\r\n            }\r\n            else\r\n            {\r\n                _products.UpdateProduct(product);\r\n            }\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult DeleteProduct(Product product)\r\n        {\r\n            _products.DeleteProduct(product);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n    }\r\n<\/pre>\n<p>\u041f\u0456\u0434 \u0447\u0430\u0441 \u0437&#8217;\u044f\u0441\u0443\u0432\u0430\u043d\u043d\u044f, \u0447\u0438 \u0431\u0430\u0436\u0430\u0454 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0443\u0432\u0430\u0442\u0438 \u043d\u0430\u044f\u0432\u043d\u0438\u0439 \u043e\u0431&#8217;\u0454\u043a\u0442 \u0430\u0431\u043e \u0436 \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u043d\u043e\u0432\u0438\u0439, \u043e\u0431&#8217;\u0454\u0434\u043d\u0430\u043d\u0456 \u0434\u0456\u0457 \u0441\u043f\u0438\u0440\u0430\u044e\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0434\u043b\u044f Id int.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440 \u043e\u043d\u043e\u0432\u0438\u043c\u043e \u043f\u043e\u0434\u0430\u043d\u043d\u044f <strong>Index<\/strong>, \u044f\u043a\u0435 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0437\u043c\u0456\u043d\u0438, \u0432\u043d\u0435\u0441\u0435\u043d\u0456 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0412\u0441\u0435 \u0442\u043e\u0432\u0430\u0440\u044b\";\r\n}\r\n@model IQueryable&lt;Product&gt;\r\n\r\n&lt;h3 class=\"p-2 bg-primary text-white text-center\"&gt;\u0422\u043e\u0432\u0430\u0440\u044b&lt;\/h3&gt; &lt;div class=\"container\"&gt;\r\n\r\n    &lt;div class=\"row\"&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0417\u0430\u043a\u0443\u043f\u043e\u0447\u043d\u0430\u044f \u0446\u0435\u043d\u0430&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0420\u043e\u0437\u043d\u0438\u0447\u043d\u0430\u044f \u0446\u0435\u043d\u0430&lt;\/div&gt;\r\n        &lt;div class=\"col\"&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n\r\n    @foreach (Product product in Model)\r\n    {\r\n        &lt;div class=\"row \u0440-2\"&gt;\r\n            &lt;div class=\"col\"&gt;@product.Name&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@product.Category&lt;\/div&gt;\r\n            &lt;div class=\"col text-right\"&gt;@product.PurchasePrice&lt;\/div&gt;\r\n            &lt;div class=\"col text-right\"&gt;@product.RetailPrice&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;\r\n                &lt;form asp-action=\"DeleteProduct\" method=\"post\"&gt;\r\n                    &lt;input type=\"hidden\" name=\"Id\" value=\"@product.Id\"&gt;\r\n                                    &lt;a asp-action=\"UpdateProduct\" asp-route-id=\"@product.Id\" class=\"btn btn-outline-primary\"&gt;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&lt;\/a&gt;\r\n&lt;button type=\"submit\" class=\"btn btn-outline-danger\"&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c&lt;\/button&gt;\r\n                &lt;\/form&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    }\r\n\r\n    &lt;div class=\"text-cente r \u0440-2\"&gt;\r\n        &lt;a asp-action=\"UpdateProduct\" asp-route-id=\"0\" class=\"btn btn-primary\"&gt;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&lt;\/a&gt;\r\n    &lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432\u0448\u0438 \u0434\u043e\u0434\u0430\u0442\u043e\u043a, \u0432\u0438 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0435 \u0442\u0430\u043a\u0438\u0439 \u0432\u043c\u0456\u0441\u0442:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-222 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1-4.png\" alt=\"\u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d c#\" width=\"1003\" height=\"786\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1-4.png 1003w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1-4-300x235.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1-4-768x602.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/p>\n<p>\u0412\u0438\u043a\u043e\u043d\u0430\u0439\u0442\u0435 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0432\u0441\u0456\u0445 \u0434\u0430\u043d\u0438\u0445 \u0456\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u0456.<\/p>\n<h2 id=\"addingrelations\">\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u0434\u043e \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445<\/h2>\n<p>\u041d\u0430\u0440\u0430\u0437\u0456 \u043a\u043e\u0436\u0435\u043d \u043e\u0431&#8217;\u0454\u043a\u0442 <strong>Product<\/strong> \u0441\u0442\u0432\u043e\u0440\u044e\u0454\u0442\u044c\u0441\u044f \u0437\u0456 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f\u043c \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0435\u0439 <strong>Category<\/strong>, \u044f\u043a\u0435 \u043c\u0430\u0454 \u0442\u0438\u043f <strong>string<\/strong>. \u0423 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0454\u043a\u0442\u0456 \u043f\u0438\u0442\u0430\u043d\u043d\u044f \u043b\u0438\u0448\u0435 \u0432 \u0442\u043e\u043c\u0443, \u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0447\u0430\u0441\u0443 \u043c\u0438\u043d\u0435 \u0434\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u0457, \u043a\u043e\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043c\u0438\u043b\u043a\u0438 \u0442\u043e\u0432\u0430\u0440 \u0431\u0443\u0434\u0435 \u043f\u043e\u043c\u0456\u0449\u0435\u043d\u043e \u0432 \u043d\u0435\u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044e. \u0429\u043e\u0431 \u0443\u043d\u0438\u043a\u043d\u0443\u0442\u0438 \u043f\u043e\u0434\u0456\u0431\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0434\u0430\u043d\u0456 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u043d\u043a\u0443 \u043c\u043e\u0436\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u0437 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f\u043c \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u044c, \u0443 \u043f\u0456\u0434\u0441\u0443\u043c\u043a\u0443 \u0441\u043a\u043e\u0440\u043e\u0447\u0443\u044e\u0447\u0438 \u0434\u0443\u0431\u043b\u044e\u0432\u0430\u043d\u043d\u044f \u0456 \u0433\u0430\u0440\u0430\u043d\u0442\u0443\u044e\u0447\u0438 \u0431\u0435\u0437\u043f\u0435\u043a\u0443.<\/p>\n<h2>\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043a\u043b\u0430\u0441\u0443 \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445<\/h2>\n<p>\u0412\u0456\u0434\u043f\u0440\u0430\u0432\u043d\u043e\u044e \u0442\u043e\u0447\u043a\u043e\u044e \u0441\u0442\u0430\u043d\u0435 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0443 \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445. \u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Models<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>Category.cs<\/strong> \u0456 \u0432\u0438\u0437\u043d\u0430\u0447\u0442\u0435 \u0432 \u043d\u044c\u043e\u043c\u0443 \u043a\u043b\u0430\u0441, \u044f\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0456:<\/p>\n<pre class=\"lang:default decode:true \">public class Category\r\n    {\r\n        public int Id { get; set; } \r\n        public string Name { get; set; }\r\n        public string Description { get; set; }\r\n    }\r\n<\/pre>\n<p>\u041a\u043b\u0430\u0441 <strong>Category<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0454 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044e \u0442\u043e\u0432\u0430\u0440\u0456\u0432. \u0412\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c Id \u043c\u0456\u0441\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u0438\u0439 \u043a\u043b\u044e\u0447, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0434\u043b\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0435\u0439 Name \u0456 Description \u0431\u0443\u0434\u0443\u0442\u044c \u043d\u0430\u0434\u0430\u043d\u0456 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0435\u043c \u043f\u0456\u0434 \u0447\u0430\u0441 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043d\u043e\u0432\u043e\u0457 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 \u0442\u0430 \u0457\u0457 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0432 \u0411\u0414.<\/p>\n<h2 id=\"creatingrelations\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0442\u043e\u0441\u0443\u043d\u043a\u0456\u0432<\/h2>\n<p>\u041d\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u043a\u0440\u043e\u0446\u0456 \u0441\u0442\u0432\u043e\u0440\u044e\u0454\u0442\u044c\u0441\u044f \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u043c\u0456\u0436 \u0434\u0432\u043e\u043c\u0430 \u043a\u043b\u0430\u0441\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445, \u0449\u043e \u0440\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0448\u043b\u044f\u0445\u043e\u043c \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0435\u0439 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0437 \u043a\u043b\u0430\u0441\u0456\u0432. \u0423 \u0431\u0443\u0434\u044c-\u044f\u043a\u043e\u043c\u0443 \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u0456 \u043c\u0456\u0436 \u0434\u0430\u043d\u0438\u043c\u0438 \u043e\u0434\u0438\u043d \u0456\u0437 \u043a\u043b\u0430\u0441\u0456\u0432 \u0432\u0456\u0434\u043e\u043c\u0438\u0439 \u044f\u043a \u0437\u0430\u043b\u0435\u0436\u043d\u0430 \u0441\u0443\u0442\u043d\u0456\u0441\u0442\u044c \u0456 \u0441\u0430\u043c\u0435 \u0434\u043e \u043d\u044c\u043e\u0433\u043e \u0434\u043e\u0434\u0430\u044e\u0442\u044c\u0441\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456. \u0429\u043e\u0431 \u0437&#8217;\u044f\u0441\u0443\u0432\u0430\u0442\u0438, \u044f\u043a\u0438\u0439 \u043a\u043b\u0430\u0441 \u0454 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u044e \u0441\u0443\u0442\u043d\u0456\u0441\u0442\u044e, \u043f\u043e\u0441\u0442\u0430\u0432\u0442\u0435 \u0441\u043e\u0431\u0456 \u0437\u0430\u043f\u0438\u0442\u0430\u043d\u043d\u044f, \u043e\u0431&#8217;\u0454\u043a\u0442 \u044f\u043a\u043e\u0433\u043e \u0437 \u0442\u0438\u043f\u0456\u0432 \u043d\u0435 \u043c\u043e\u0436\u0435 \u0456\u0441\u043d\u0443\u0432\u0430\u0442\u0438 \u0431\u0435\u0437 \u0456\u043d\u0448\u043e\u0433\u043e. \u0423 \u0432\u0438\u043f\u0430\u0434\u043a\u0443 \u0434\u043e\u0434\u0430\u0442\u043a\u0430 <strong>GameStore<\/strong> \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044f \u0437\u0434\u0430\u0442\u043d\u0430 \u0456\u0441\u043d\u0443\u0432\u0430\u0442\u0438, \u043d\u0430\u0432\u0456\u0442\u044c \u043d\u0435 \u043c\u0430\u044e\u0447\u0438 \u0432 \u0441\u043e\u0431\u0456 \u0442\u043e\u0432\u0430\u0440\u0456\u0432, \u0430\u043b\u0435 \u043a\u043e\u0436\u0435\u043d \u0442\u043e\u0432\u0430\u0440 \u043c\u0430\u0454 \u043d\u0430\u043b\u0435\u0436\u0430\u0442\u0438 \u0434\u043e \u044f\u043a\u043e\u0457\u0441\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 &#8211; \u0456 \u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u0432 \u0442\u0430\u043a\u0456\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u0457 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u044e \u0441\u0443\u0442\u043d\u0456\u0441\u0442\u044e \u0432\u0438\u044f\u0432\u043b\u044f\u0454\u0442\u044c\u0441\u044f \u043a\u043b\u0430\u0441 Product. \u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043a\u043b\u0430\u0441 <strong>Product<\/strong> \u0434\u0432\u0456 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456, \u044f\u043a\u0456 \u0441\u0442\u0432\u043e\u0440\u044e\u044e\u0442\u044c \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u0437 \u043a\u043b\u0430\u0441\u043e\u043c <strong>Category<\/strong>:<\/p>\n<pre class=\"lang:default decode:true \">public class Product\r\n    {\r\n        public int Id { get; set; }\r\n        public string Name { get; set; }\r\n        \/\/public string Category { get; set; }\r\n        public decimal PurchasePrice { get; set; }\r\n        public decimal RetailPrice { get; set; }\r\n\r\n        public int CategoryId { get; set; }\r\n        public Category Category { get; set; }\r\n    }\r\n<\/pre>\n<p>\u041f\u0435\u0440\u0448\u0438\u043c \u0442\u0443\u0442 \u0434\u043e\u0434\u0430\u043d\u043e \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>\u0421ategoryId<\/strong>, \u0449\u043e \u0454 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043e\u043c \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 \u0437\u043e\u0432\u043d\u0456\u0448\u043d\u044c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u044f\u043a\u0443 \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u0431\u0443\u0434\u0435 \u043f\u0440\u0438 \u043c\u0456\u043d\u044f\u0442\u0438 \u0434\u043b\u044f \u0432\u0456\u0434\u0441\u0442\u0435\u0436\u0435\u043d\u043d\u044f \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u0437\u0430 \u0440\u0430\u0445\u0443\u043d\u043e\u043a \u043f\u0440\u0438\u0441\u0432\u043e\u0454\u043d\u043d\u044f \u0457\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0449\u043e \u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0443\u0454 \u043e\u0431&#8217;\u0454\u043a\u0442 Category. \u0406\u043c&#8217;\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 \u0437\u043e\u0432\u043d\u0456\u0448\u043d\u044c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441\u043a\u043b\u0430\u0434\u0430\u0454\u0442\u044c\u0441\u044f \u0437 \u0456\u043c\u0435\u043d\u0456 \u043a\u043b\u0430\u0441\u0443 \u043f\u043b\u044e\u0441 \u0456\u043c&#8217;\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0434\u0430\u044e\u0447\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0456 <strong>Categoryld<\/strong>.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0430 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u0437\u0430\u043c\u0456\u043d\u044e\u0454 \u043d\u0430\u044f\u0432\u043d\u0443 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c <strong>Category<\/strong> \u0456 \u044f\u0432\u043b\u044f\u0454 \u0441\u043e\u0431\u043e\u044e \u043f\u0440\u0438\u043a\u043b\u0430\u0434 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u043e\u0457 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456. \u0406\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0415ntity Framework Core \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0442\u0438\u043c\u0435 \u0446\u044e \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u043e\u0431&#8217;\u0454\u043a\u0442\u043e\u043c \u0421ategory, \u044f\u043a\u0438\u0439 \u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0443\u0454\u0442\u044c\u0441\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044e \u0437\u043e\u0432\u043d\u0456\u0448\u043d\u044c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0449\u043e \u0440\u043e\u0431\u0438\u0442\u044c \u0439\u043e\u0433\u043e \u0431\u0456\u043b\u044c\u0448 \u043f\u0440\u0438\u0434\u0430\u0442\u043d\u0438\u043c \u0434\u043b\u044f \u0440\u043e\u0431\u043e\u0442\u0438 \u0437 \u0434\u0430\u043d\u0438\u043c\u0438 \u0432 \u0411\u0414.<\/p>\n<h2 id=\"updatecontent\">\u041e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u0442\u0430 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0445\u043e\u0432\u0438\u0449\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0435\u043d\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u0434\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 Category \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043a\u043b\u0430\u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u0411\u0414 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c <strong>DbSet&lt;T&gt;<\/strong>:<\/p>\n<pre class=\"lang:default decode:true \">public class ApplicationContext : DbContext\r\n    {\r\n        public ApplicationContext(DbContextOptions&lt;ApplicationContext&gt; context) : base(context)\r\n        {\r\n\r\n        }\r\n        public DbSet&lt;Product&gt; Products { get; set; }\r\n        public DbSet&lt;Category&gt; Categories { get; set; }\r\n    }\r\n<\/pre>\n<p>\u041d\u043e\u0432\u0430 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u0441\u043b\u0456\u0434\u0443\u0454 \u0437\u0430 \u0442\u0438\u043c \u0441\u0430\u043c\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c, \u0449\u043e \u0439 \u043d\u0430\u044f\u0432\u043d\u0430 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c: \u0432\u043e\u043d\u0430 \u043e\u0433\u043e\u043b\u043e\u0448\u0435\u043d\u0430 \u044f\u043a \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c public \u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0456\u044f\u043c\u0438 get \u0456 set, \u0430 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 DbSet&lt;T&gt;, \u0434\u0435 \u0422 &#8211; \u043a\u043b\u0430\u0441, \u044f\u043a\u0438\u0439 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0442\u0438 \u0432 \u0411\u0414.<\/p>\n<p>\u041a\u043e\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445 \u0440\u043e\u0437\u0448\u0438\u0440\u044e\u0454\u0442\u044c\u0441\u044f, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0438\u0442\u0438 \u0440\u0435\u0448\u0442\u0443 \u043a\u043e\u0434\u0443 \u0432 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u043d\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0434\u043e \u043d\u043e\u0432\u0438\u0445 \u0442\u0438\u043f\u0456\u0432 \u0434\u0430\u043d\u0438\u0445, \u0434\u043e\u0434\u0430\u0432\u0448\u0438 \u0447\u043b\u0435\u043d\u0438 \u0434\u043e \u043d\u0430\u044f\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0443 \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0430\u0431\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0432\u0448\u0438 \u043d\u043e\u0432\u0438\u0439 \u0442\u0430\u043a\u0438\u0439 \u043a\u043b\u0430\u0441. \u0414\u043b\u044f \u0434\u043e\u0434\u0430\u0442\u043a\u0430 <strong>GameStore<\/strong> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0442\u0432\u043e\u0440\u0438\u043c\u043e \u043e\u043a\u0440\u0435\u043c\u0435 \u0441\u0445\u043e\u0432\u0438\u0449\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0449\u043e\u0431 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0443\u0432\u0430\u0442\u0438, \u044f\u043a \u0446\u0435 \u0440\u043e\u0431\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0423 \u043f\u0430\u043f\u043a\u0443 <strong>Interfaces<\/strong>, \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>ICategory<\/strong>, \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public interface ICategory\r\n    {\r\n        IEnumerable&lt;Category&gt; GetAllCategories();\r\n        void AddCategory(Category category);\r\n        void UpdateCategory(Category category);\r\n        void DeleteCategory(Category category);\r\n    }\r\n<\/pre>\n<p>\u0423 \u043f\u0430\u043f\u043a\u0443 <strong>Repository<\/strong> \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441 <strong>CategoryRepository<\/strong>, \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">    {\r\n        private ApplicationContext _context;\r\n\r\n        public CategoryRepository(ApplicationContext context)\r\n        {\r\n            _context = context;\r\n        }\r\n\r\n        public IEnumerable&lt;Category&gt; GetAllCategories()\r\n        {\r\n            return _context.Categories;\r\n        }\r\n\r\n        public void AddCategory(Category category)\r\n        {\r\n            _context.Categories.Add(category);\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void UpdateCategory(Category category)\r\n        {\r\n            _context.Categories.Update(category);\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void DeleteCategory(Category category)\r\n        {\r\n            _context.Categories.Remove(category);\r\n            _context.SaveChanges();\r\n        }\r\n    }\r\n<\/pre>\n<p>\u041c\u0438 \u0441\u0442\u0432\u043e\u0440\u0438\u043b\u0438 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0456 \u043a\u043b\u0430\u0441 \u0440\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u0457, \u0437\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0456\u0454\u044e, \u044f\u043a \u0456 \u0437 \u043a\u043b\u0430\u0441\u043e\u043c Product.<\/p>\n<p>\u0417\u0430\u0440\u0435\u0454\u0441\u0442\u0440\u0443\u0439\u0442\u0435 \u0441\u0445\u043e\u0432\u0438\u0449\u0435 \u0442\u0430 \u0439\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u044e \u0432 \u043a\u043b\u0430\u0441\u0456 <strong>Program<\/strong> \u0434\u043b\u044f \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u0456\u0437 \u0437\u0430\u0441\u043e\u0431\u043e\u043c \u0432\u043f\u0440\u043e\u0432\u0430\u0434\u0436\u0435\u043d\u043d\u044f \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre class=\"lang:default decode:true \">builder.Services.AddTransient&lt;ICategory, CategoryRepository&gt;();<\/pre>\n<h2 id=\"addmigration\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0442\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457<\/h2>\n<p>\u0406\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u043d\u0435 \u0437\u043c\u043e\u0436\u0435 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0442\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 Category \u0434\u043e\u0442\u0438, \u0434\u043e\u043a\u0438 \u0411\u0414 \u043d\u0435 \u0431\u0443\u0434\u0435 \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0434\u043b\u044f \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e\u0441\u0442\u0456 \u0437\u043c\u0456\u043d\u0430\u043c, \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u043c \u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445. \u0429\u043e\u0431 \u043e\u043d\u043e\u0432\u0438\u0442\u0438 \u0411\u0414, \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u0456 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0434\u043e \u043d\u0435\u0457 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u044e.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457 \u0443 \u0432\u0456\u043a\u043d\u0456 <strong>Package Manager Console<\/strong> \u0432\u0432\u0435\u0434\u0456\u0442\u044c \u0442\u0430\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre class=\"lang:default decode:true \">Add-Migration AddCategories<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-223 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/2-4.png\" alt=\"asp.net core migration init\" width=\"461\" height=\"205\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/2-4.png 461w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/2-4-300x133.png 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/p>\n<p>\u0414\u043b\u044f \u0432\u0438\u043a\u043e\u043d\u0430\u043d\u043d\u044f \u0456\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0456\u0439 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457, \u0443 \u0432\u0456\u043a\u043d\u0456 <strong>Package Manager Console<\/strong> \u0432\u0438\u043a\u043e\u043d\u0430\u0439\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre class=\"lang:default decode:true \">Update-Database<\/pre>\n<p>\u041f\u0435\u0440\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0432\u043e\u0440\u044e\u0454 \u043d\u043e\u0432\u0443 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u044e \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>Categories<\/strong>, \u044f\u043a\u0430 \u043c\u0456\u0441\u0442\u0438\u0442\u0438\u043c\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0438, \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u0456 \u0434\u043b\u044f \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0411\u0414 \u0434\u043e \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u043d\u043d\u044f \u043d\u043e\u0432\u0438\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432. \u0414\u0440\u0443\u0433\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u0438\u043a\u043e\u043d\u0443\u0454 \u0442\u0430\u043a\u0456 \u043a\u043e\u043c\u0430\u043d\u0434\u0438 \u0434\u043b\u044f \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0411\u0414.<\/p>\n<h2 id=\"createcontroller\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430 \u0442\u0430 \u043f\u043e\u0434\u0430\u043d\u043d\u044f<\/h2>\n<p>\u041c\u0438 \u0441\u0442\u0432\u043e\u0440\u0438\u043b\u0438 \u043e\u0431\u043e\u0432&#8217;\u044f\u0437\u043a\u043e\u0432\u0435 \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u043c\u0456\u0436 \u043a\u043b\u0430\u0441\u0430\u043c\u0438 <strong>Product<\/strong> \u0456 <strong>Category<\/strong>, \u0442\u043e\u0431\u0442\u043e \u043a\u043e\u0436\u0435\u043d \u043e\u0431&#8217;\u0454\u043a\u0442 Product \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 \u0430\u0441\u043e\u0446\u0456\u0439\u043e\u0432\u0430\u043d\u0438\u0439 \u0437 \u043e\u0431&#8217;\u0454\u043a\u0442\u043e\u043c Category. \u041f\u0440\u0438 \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u0456 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0443 \u043a\u043e\u0440\u0438\u0441\u043d\u043e \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0443\u0432\u0430\u0442\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0441\u043e\u0431\u0430\u043c\u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0456\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 Category \u0432 \u0411\u0414. \u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Controllers<\/strong> \u0444\u0430\u0439\u043b \u043a\u043b\u0430\u0441\u0443 \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>CategoriesController.cs<\/strong> \u0456 \u043f\u043e\u043c\u0456\u0441\u0442\u0456\u0442\u044c \u0443 \u043d\u044c\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre class=\"lang:default decode:true \">public class CategoriesController : Controller\r\n    {\r\n        private readonly ICategory _categories;\r\n\r\n        public CategoriesController(ICategory categories)\r\n        {\r\n            _categories = categories;\r\n        }\r\n        public IActionResult Index()\r\n        {\r\n            return View(_categories.GetAllCategories());\r\n        }\r\n        [HttpPost]\r\n        public IActionResult AddCategory(Category category)\r\n        {\r\n            _categories.AddCategory(category);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n        public IActionResult EditCategory(long id)\r\n        {\r\n            ViewBag.Editid = id;\r\n            return View(nameof(Index), _categories.GetAllCategories());\r\n        }\r\n        [HttpPost]\t\r\n        public IActionResult UpdateCategory(Category category)\r\n        {\r\n            _categories.UpdateCategory(category);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult DeleteCategory(Category category)\r\n        {\r\n            _categories.DeleteCategory(category);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n    }\r\n<\/pre>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 <strong>Categories<\/strong> \u043f\u0440\u0438\u0439\u043c\u0430\u0454 \u0443 \u0441\u0432\u043e\u0454\u043c\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0456 \u043e\u0431&#8217;\u0454\u043a\u0442 \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u0434\u043e \u0434\u0430\u043d\u0438\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0439 \u0456 \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u0454 \u0434\u0456\u0457, \u044f\u043a\u0456 \u043f\u0456\u0434\u0442\u0440\u0438\u043c\u0443\u044e\u0442\u044c \u0437\u0430\u043f\u0438\u0442\u0443\u0432\u0430\u043d\u043d\u044f \u0411\u0414, \u0430 \u0442\u0430\u043a\u043e\u0436 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f, \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 Category. \u0429\u043e\u0431 \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0438\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 \u043f\u043e\u0434\u0430\u043d\u043d\u044f\u043c, \u0441\u0442\u0432\u043e\u0440\u0456\u0442\u044c \u043f\u0430\u043f\u043a\u0443 <strong>Views\/Categories<\/strong> \u0456 \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043d\u0435\u0457 \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>Index.cshtml<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0412\u0441\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438\";\r\n}\r\n@model IEnumerable&lt;Category&gt;\r\n\r\n&lt;h3 class=\"p-2 bg-primary text-white text-center\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438&lt;\/h3&gt;\r\n&lt;div class=\"container-fluid mt-3\"&gt;\r\n    &lt;div class=\"row\"&gt;\r\n        &lt;div class=\"col-1 fw-bold\"&gt;Id&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435&lt;\/div&gt;\r\n        &lt;div class=\"col-3\"&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    @if (ViewBag.EditId == null)\r\n    {\r\n        &lt;form asp-action=\"AddCategory\" method=\"post\"&gt;\r\n            @Html.Partial(\"CategoryEditor\", new Category())\r\n        &lt;\/form&gt;\r\n    }\r\n    @foreach (Category c in Model)\r\n    {\r\n        @if (c.Id == ViewBag.EditId)\r\n        {\r\n            &lt;form asp-action=\"UpdateCategory\" method=\"post\"&gt;\r\n                &lt;input type=\"hidden\" name=\"Id\" value=\"@c.Id\" \/&gt;\r\n                @Html.Partial(\"CategoryEditor\",c)\r\n            &lt;\/form&gt;\r\n        }\r\n        else\r\n        {\r\n            &lt;div class=\"row p-2\"&gt;\r\n                &lt;div class=\"col-1\"&gt;@c.Id&lt;\/div&gt;\r\n                &lt;div class=\"col\"&gt;@c.Name&lt;\/div&gt;\r\n                &lt;div class=\"col\"&gt;@c.Description&lt;\/div&gt;\r\n                &lt;div class=\"col-3\"&gt;\r\n                    &lt;form asp-action=\"DeleteCategory\" method=\"post\"&gt;\r\n                        &lt;input type=\"hidden\" name=\"Id\" value=\"@c.Id\" \/&gt;\r\n                        &lt;a asp-action=\"EditCategory\" asp-route-id=\"@c.Id\" class=\"btn btn-outline-primary\"&gt;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&lt;\/a&gt;\r\n                        &lt;button type=\"submit\" class=\"btn btn-outline-danger\"&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        }\r\n    }\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u041f\u043e\u0434\u0430\u043d\u043d\u044f <strong>Index<\/strong> \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 \u0454\u0434\u0438\u043d\u0438\u0439 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043a\u0435\u0440\u0443\u0432\u0430\u043d\u043d\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044f\u043c\u0438 \u0442\u0430 \u0434\u043e\u0440\u0443\u0447\u0430\u0454 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0456 \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 \u0447\u0430\u0441\u0442\u043a\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u0434\u0430\u043d\u043d\u044e. \u0429\u043e\u0431 \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u0447\u0430\u0441\u0442\u043a\u043e\u0432\u0435 \u043f\u043e\u0434\u0430\u043d\u043d\u044f, \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Views\/Categories<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>CategoryEditor.cshtml<\/strong> \u0456 \u043f\u043e\u043c\u0456\u0441\u0442\u0456\u0442\u044c \u0443 \u043d\u044c\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0439 \u0432\u043c\u0456\u0441\u0442:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438\";\r\n}\r\n@model Category\r\n\r\n&lt;div class=\"row \u0440-2\"&gt;\r\n    &lt;div class=\"col-1\"&gt;&lt;\/div&gt;\r\n    &lt;div class=\"col\"&gt;\r\n        &lt;input asp-for=\"Name\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"col\"&gt;\r\n        &lt;input asp-for=\"Description\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"col-3\"&gt;\r\n        @if (Model.Id == 0)\r\n        {\r\n            &lt;button type=\"submit\" class=\"btn btn-primary\"&gt;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&lt;\/button&gt;\r\n        }\r\n        else\r\n        {\r\n            &lt;button type=\"submit\" class=\"btn btn-outline-primary\"&gt;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/button&gt;\r\n            &lt;a asp-action=\"Index\" class=\"btn btn-outline-secondary\"&gt;\u041e\u0442\u043c\u0435\u043d\u0430&lt;\/a&gt;\r\n        }\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0435\u0433\u0448\u0435\u043d\u043d\u044f \u043f\u0435\u0440\u0435\u043c\u0456\u0449\u0435\u043d\u043d\u044f \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u043c \u0443 \u0444\u0430\u0439\u043b <strong>Views &#8211; Shared &#8211; _Layout.cshtml<\/strong> \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre class=\"lang:default decode:true\">\/\/...\r\n                &lt;div class=\"navbar-collapse collapse d-sm-inline-flex justify-content-between\"&gt;\r\n                    &lt;ul class=\"navbar-nav flex-grow-1\"&gt;\r\n                        &lt;li class=\"nav-item\"&gt;\r\n                            &lt;a class=\"nav-link text-dark\" asp-area=\"\" asp-controller=\"Home\" asp-action=\"Index\"&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt;\r\n                        &lt;\/li&gt;\r\n                        &lt;li class=\"nav-item\"&gt;\r\n                            &lt;a class=\"nav-link text-dark\" asp-area=\"\" asp-controller=\"Categories\" asp-action=\"Index\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438&lt;\/a&gt;\r\n                        &lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0456\u0442\u044c \u0434\u043e\u0434\u0430\u0442\u043e\u043a \u0456 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0442\u0435 \u0439\u043e\u0433\u043e \u0440\u043e\u0431\u043e\u0442\u0443.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-224 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/3-4.png\" alt=\"adding items c#\" width=\"1201\" height=\"783\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/3-4.png 1201w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/3-4-300x196.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/3-4-1024x668.png 1024w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/3-4-768x501.png 768w\" sizes=\"auto, (max-width: 1201px) 100vw, 1201px\" \/><\/p>\n<h2 id=\"createdatabase\">\u0417\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044f\u043c\u0438<\/h2>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0456\u0442\u044c \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u043d\u043e\u043a \u0456 \u0434\u043e\u0434\u0430\u0439\u0442\u0435 3 \u0431\u0443\u0434\u044c-\u044f\u043a\u0456 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456 &#8220;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457&#8221;:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-225\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/4-3.png\" alt=\"asp.net core add category\" width=\"1201\" height=\"783\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/4-3.png 1201w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/4-3-300x196.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/4-3-1024x668.png 1024w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/4-3-768x501.png 768w\" sizes=\"auto, (max-width: 1201px) 100vw, 1201px\" \/><\/p>\n<h2 id=\"createdata\">\u0420\u043e\u0431\u043e\u0442\u0430 \u0437 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u043c\u0438 \u0434\u0430\u043d\u0438\u043c\u0438<\/h2>\n<p>\u0406\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework \u0421ore \u0456\u0433\u043d\u043e\u0440\u0443\u0454 \u0432\u0456\u0434\u043d\u043e\u0441\u0438\u043d\u0438, \u044f\u043a\u0449\u043e \u0442\u0456\u043b\u044c\u043a\u0438 \u0457\u0445 \u044f\u0432\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u044c \u0443 \u0437\u0430\u043f\u0438\u0442\u0438. \u0426\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u0456 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456, \u044f\u043a-\u043e\u0442 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c Category, \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0432 \u043a\u043b\u0430\u0441\u0456 <strong>Product<\/strong>, \u0437\u0430 \u0437\u0430\u043c\u043e\u0432\u0447\u0443\u0432\u0430\u043d\u043d\u044f\u043c \u0437\u0430\u043b\u0438\u0448\u0430\u0442\u0438\u043c\u0443\u0442\u044c\u0441\u044f \u0440\u0456\u0432\u043d\u0438\u043c\u0438 null. \u0420\u043e\u0437\u0448\u0438\u0440\u044e\u0432\u0430\u043b\u044c\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>Include()<\/strong> \u0437\u0430\u0441\u0442\u043e\u0441\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0456 EF \u043f\u0440\u043e \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u0456\u0441\u0442\u044c \u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u043e\u0457 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u043c\u0438 \u0434\u0430\u043d\u0438\u043c\u0438.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c\u043e \u0432 \u043a\u043b\u0430\u0441 <strong>ProductRepository<\/strong> \u0456 \u0437\u043c\u0456\u043d\u0438\u043c\u043e \u0439\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u044e, \u0432\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457:<\/p>\n<pre class=\"lang:default decode:true \">public class ProductRepository : IProduct\r\n    {\r\n        private ApplicationContext _context;\r\n\r\n        public ProductRepository(ApplicationContext context)\r\n        {\r\n            _context = context;\r\n        }\r\n\r\n        public void AddProduct(Product product)\r\n        {\r\n            _context.Products.Add(product);\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public IEnumerable&lt;Product&gt; GetAllProducts()\r\n        {\r\n            return _context.Products.Include(e =&gt; e.Category);\r\n        }\r\n\r\n        public Product GetProduct(int id)\r\n        {\r\n            return _context.Products.Include(e =&gt; e.Category).FirstOrDefault(e =&gt; e.Id == id);\r\n        }\r\n\r\n        public void UpdateProduct(Product product)\r\n        {\r\n            Product product2 = _context.Products.Find(product.Id);\r\n            product2.Name = product.Name;\r\n            \/\/product2.Category = product.Category;\r\n            product2.RetailPrice = product.RetailPrice;\r\n            product2.PurchasePrice = product.PurchasePrice;\r\n            product2.CategoryId = product.CategoryId;\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void UpdateAll(Product[] products)\r\n        {\r\n            \/\/ _context.Products.UpdateRange(products);\r\n            Dictionary&lt;int, Product&gt; data = products.ToDictionary(e =&gt; e.Id);\r\n            IEnumerable&lt;Product&gt; baseline = _context.Products.Where(e =&gt; data.Keys.Contains(e.Id));\r\n            foreach (Product product in baseline)\r\n            {\r\n                Product requestProduct = data[product.Id];\r\n                product.Name = requestProduct.Name;\r\n                product.Category = requestProduct.Category;\r\n                product.RetailPrice = requestProduct.RetailPrice;\r\n                product.PurchasePrice = requestProduct.PurchasePrice;\r\n            }\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void DeleteProduct(Product product)\r\n        {\r\n            _context.Products.Remove(product);\r\n            _context.SaveChanges();\r\n        }\r\n    }\r\n<\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <strong>Include()<\/strong> \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0456 \u0456\u043c\u0435\u043d Microsoft.Entity FrameworkCore, \u0432\u0456\u043d \u043f\u0440\u0438\u0439\u043c\u0430\u0454 \u043b\u044f\u043c\u0431\u0434\u0430-\u0432\u0438\u0440\u0430\u0437, \u0449\u043e \u0432\u0438\u0431\u0438\u0440\u0430\u0454 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u0443 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c, \u044f\u043a\u0443 \u0431\u0430\u0436\u0430\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0438 \u0434\u043e \u0437\u0430\u043f\u0438\u0442\u0443. \u041c\u0435\u0442\u043e\u0434 Find(), \u0449\u043e \u0437\u0430\u0441\u0442\u043e\u0441\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0443 GetProduct(), \u043d\u0435 \u043c\u043e\u0436\u0435 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438\u0441\u044f \u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Include(), \u0442\u043e\u043c\u0443 \u0432\u0456\u043d \u0437\u0430\u043c\u0456\u043d\u0435\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c First(), \u044f\u043a\u0438\u0439 \u043f\u0440\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u043e \u0442\u043e\u0433\u043e \u0436 \u0441\u0430\u043c\u043e\u0433\u043e \u0435\u0444\u0435\u043a\u0442\u0443. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0445 \u0437\u043c\u0456\u043d \u043f\u043e\u043b\u044f\u0433\u0430\u0454 \u0432 \u0442\u043e\u043c\u0443, \u0449\u043e \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u0431\u0443\u0434\u0435 \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0442\u0438 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u0443 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c Product.\u0421ategory \u0434\u043b\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 Product, \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0445 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044e Products \u0456 \u043c\u0435\u0442\u043e\u0434\u043e\u043c GetProduct().<\/p>\n<p>\u0417\u0432\u0435\u0440\u043d\u0456\u0442\u044c \u0443\u0432\u0430\u0433\u0443 \u043d\u0430 \u0437\u043c\u0456\u043d\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0456 <strong>UpdateProduct()<\/strong>. \u041f\u043e-\u043f\u0435\u0440\u0448\u0435, \u0432\u0438\u0445\u0456\u0434\u043d\u0456 \u0434\u0430\u043d\u0456 \u0437\u0430\u043f\u0438\u0442\u0443\u044e\u0442\u044c\u0441\u044f \u0431\u0435\u0437\u043f\u043e\u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 GetProduct(), \u0442\u043e\u043c\u0443 \u0449\u043e \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0434\u0430\u043d\u0456 \u043f\u0456\u0434 \u0447\u0430\u0441 \u0432\u0438\u043a\u043e\u043d\u0430\u043d\u043d\u044f \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u043d\u0435\u0431\u0430\u0436\u0430\u043d\u043e. \u041f\u043e-\u0434\u0440\u0443\u0433\u0435, \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u043e\u0432\u0430\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0449\u043e \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0454 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c Category, \u0456 \u0434\u043e\u0434\u0430\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u044f\u043a\u0438\u0439 \u043d\u0430\u0442\u043e\u043c\u0456\u0441\u0442\u044c \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0454 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u0421ategoryid. \u0412\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 \u0437\u043e\u0432\u043d\u0456\u0448\u043d\u044c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 &#8211; \u0432\u0441\u0435, \u0449\u043e \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0456 Entity Framework Core \u0434\u043b\u044f \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f \u043c\u0456\u0436 \u0434\u0432\u043e\u043c\u0430 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 \u0432 \u0411\u0414.<\/p>\n<p><span style=\"font-family: Rokkitt, sans-serif; font-size: 1.75em;\">\u0412\u0438\u0431\u0456\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 \u0434\u043b\u044f \u0442\u043e\u0432\u0430\u0440\u0443<\/span><\/p>\n<p>\u041e\u043d\u043e\u0432\u0438\u043c\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 <strong>Home<\/strong>, \u0449\u043e\u0431 \u0432\u0456\u043d \u043c\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u0434\u0430\u043d\u0438\u0445 Category \u0447\u0435\u0440\u0435\u0437 \u0441\u0445\u043e\u0432\u0438\u0449\u0435 \u0456 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0432 \u0457\u0445 \u0441\u0432\u043e\u0454\u043c\u0443 \u043f\u043e\u0434\u0430\u043d\u043d\u044e. \u0426\u0435 \u0434\u0430\u0441\u0442\u044c \u0437\u043c\u043e\u0433\u0443 \u043f\u043e\u0434\u0430\u043d\u043d\u044f\u043c \u0437\u0430\u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0432\u0430\u0442\u0438 \u0432\u0438\u0431\u0456\u0440 \u0456\u0437 \u043f\u043e\u0432\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0439 \u043f\u0456\u0434 \u0447\u0430\u0441 \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u0430\u0431\u043e \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 Product:<\/p>\n<pre class=\"lang:default decode:true \">public class HomeController : Controller\r\n    {\r\n        private readonly IProduct _products;\r\n        private readonly ICategory _categories;\r\n\r\n        public HomeController(IProduct products, ICategory categories)\r\n        {\r\n            _products = products;\r\n            _categories = categories;\r\n        }\r\n        [HttpGet]\r\n        public IActionResult Index()\r\n        {\r\n            return View(_products.GetAllProducts());\r\n        }        \r\n        [HttpGet]\r\n        public IActionResult UpdateProduct(int id)\r\n        {\r\n            ViewBag.Categories = _categories.GetAllCategories();\r\n            return View(id == 0 ? new Product() : _products.GetProduct(id));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult UpdateProduct(Product product)\r\n        {\r\n            if (product.Id == 0)\r\n            {\r\n                _products.AddProduct(product);\r\n            }\r\n            else\r\n            {\r\n                _products.UpdateProduct(product);\r\n            }\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult DeleteProduct(Product product)\r\n        {\r\n            _products.DeleteProduct(product);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n    }\r\n<\/pre>\n<p>\u0429\u043e\u0431 \u043d\u0430\u0434\u0430\u0442\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0435\u0432\u0456 \u043c\u043e\u0436\u043b\u0438\u0432\u0456\u0441\u0442\u044c \u0432\u0438\u0431\u043e\u0440\u0443 \u043e\u0434\u043d\u0456\u0454\u0457 \u0437 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0439 \u043f\u0440\u0438 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u0456 \u0430\u0431\u043e \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u0456 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 Product, \u0434\u043e\u0434\u0430\u043c\u043e \u0432 \u043f\u043e\u0434\u0430\u043d\u043d\u044f <strong>UpdateProduct<\/strong> \u0435\u043b\u0435\u043c\u0435\u043d\u0442 select:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430\";\r\n}\r\n@model Product\r\n\r\n&lt;div class=\"p-5 text-center bg-light\"&gt;\r\n    &lt;h2 class=\"mb-3\"&gt;\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430&lt;\/h2&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;form asp-action=\"UpdateProduct\" method=\"post\"&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"Id\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"Id\" class=\"form-control\" readonly=\"readonly\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"Name\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"Name\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"Category\"&gt;&lt;\/label&gt;\r\n        &lt;select class=\"form-control\" asp-for=\"CategoryId\"&gt;\r\n        @if (Model.Id == 0)\r\n        {\r\n            &lt;option disabled selected&gt;\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e&lt;\/option&gt;\r\n        }\r\n        @foreach (Category category in ViewBag.Categories)\r\n        {\r\n            &lt;option selected=\"@(Model.Category?.Id == category.Id)\" value=\"@category.Id\"&gt;@category.Name&lt;\/option&gt;\r\n        }\r\n        &lt;\/select&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"PurchasePrice\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"PurchasePrice\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"RetailPrice\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"RetailPrice\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group text-center\"&gt;\r\n        &lt;button class=\"btn btn-primary\" type=\"submit\"&gt;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/button&gt;\r\n        &lt;a asp-action=\"Index\" class=\"btn btn-secondary\"&gt;\u041e\u0442\u043c\u0435\u043d\u0430&lt;\/a&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<p>\u0423 \u0440\u043e\u0437\u043c\u0456\u0442\u043a\u0443 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0435\u043b\u0435\u043c\u0435\u043d\u0442-\u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0447 option \u043d\u0430 \u0432\u0438\u043f\u0430\u0434\u043e\u043a, \u044f\u043a\u0449\u043e \u043f\u043e\u0434\u0430\u043d\u043d\u044f \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 <strong>Product<\/strong>, \u0456 \u043f\u0435\u0440\u0435\u0434\u0431\u0430\u0447\u0435\u043d\u043e \u0432\u0438\u0440\u0430\u0437 Razor \u0434\u043b\u044f \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 selected, \u044f\u043a\u0449\u043e \u043f\u043e\u0442\u043e\u0447\u043d\u0438\u0439 \u043e\u0431&#8217;\u0454\u043a\u0442 \u0440\u0435\u0434\u0430\u0433\u0443\u0454\u0442\u044c\u0441\u044f. \u0417\u0430\u043b\u0438\u0448\u0438\u043b\u043e\u0441\u044f \u043b\u0438\u0448\u0435 \u043e\u043d\u043e\u0432\u0438\u0442\u0438 \u043f\u043e\u0434\u0430\u043d\u043d\u044f <strong>Index<\/strong>, \u0449\u043e\u0431 \u043f\u0440\u043e\u0441\u043b\u0456\u0434\u0443\u0432\u0430\u0442\u0438 \u0437\u0430 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u043e\u044e \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044e \u0456 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0438 \u0434\u043b\u044f \u043a\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 Product \u043d\u0430\u0437\u0432\u0443 \u043e\u0431\u0440\u0430\u043d\u043e\u0457 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c\u043e \u0432 <strong>Home \/ Index.cshtml<\/strong> \u0456 \u0437\u043c\u0456\u043d\u0438\u043c\u043e \u0432\u043c\u0456\u0441\u0442:<\/p>\n<pre class=\"lang:default decode:true\">@{\r\n    ViewData[\"Title\"] = \"\u0412\u0441\u0435 \u0442\u043e\u0432\u0430\u0440\u044b\";\r\n}\r\n@model IQueryable&lt;Product&gt;\r\n\r\n&lt;h3 class=\"p-2 bg-primary text-white text-center\"&gt;\u0422\u043e\u0432\u0430\u0440\u044b&lt;\/h3&gt;\r\n&lt;div class=\"container\"&gt;\r\n\r\n    &lt;div class=\"row\"&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0417\u0430\u043a\u0443\u043f\u043e\u0447\u043d\u0430\u044f \u0446\u0435\u043d\u0430&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0420\u043e\u0437\u043d\u0438\u0447\u043d\u0430\u044f \u0446\u0435\u043d\u0430&lt;\/div&gt;\r\n        &lt;div class=\"col\"&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n\r\n    @foreach (Product product in Model)\r\n    {\r\n        &lt;div class=\"row \u0440-2\"&gt;\r\n            &lt;div class=\"col\"&gt;@product.Name&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@product.Category.Name&lt;\/div&gt;\r\n            &lt;div class=\"col text-right\"&gt;@product.PurchasePrice&lt;\/div&gt;\r\n            &lt;div class=\"col text-right\"&gt;@product.RetailPrice&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;\r\n                &lt;form asp-action=\"DeleteProduct\" method=\"post\"&gt;\r\n                    &lt;input type=\"hidden\" name=\"Id\" value=\"@product.Id\"&gt;\r\n                                    &lt;a asp-action=\"UpdateProduct\" asp-route-id=\"@product.Id\" class=\"btn btn-outline-primary\"&gt;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&lt;\/a&gt;\r\n&lt;button type=\"submit\" class=\"btn btn-outline-danger\"&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c&lt;\/button&gt;\r\n                &lt;\/form&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    }\r\n\r\n    &lt;div class=\"text-cente r \u0440-2\"&gt;\r\n        &lt;a asp-action=\"UpdateProduct\" asp-route-id=\"0\" class=\"btn btn-primary\"&gt;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&lt;\/a&gt;\r\n    &lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0456\u0442\u044c \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u043d\u043e\u043a, \u0432\u0438\u043a\u043e\u043d\u0430\u0439\u0442\u0435 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0456 \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u0442\u043e\u0432\u0430\u0440\u0443, \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0439\u0442\u0435\u0441\u044f, \u0449\u043e \u0432\u0438\u0431\u0456\u0440 \u0456 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u0457 \u043f\u0440\u0430\u0446\u044e\u0454 \u043a\u043e\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-226 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/5-1.png\" alt=\"entity framework add product\" width=\"1009\" height=\"785\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/5-1.png 1009w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/5-1-300x233.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/5-1-768x598.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/p>\n<p>\u041f\u0456\u0441\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 \u0456\u043d\u0456\u0446\u0456\u044e\u0454\u0442\u044c\u0441\u044f \u0434\u0456\u044f <strong>Index<\/strong> \u0434\u043b\u044f \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0456\u0432, \u044f\u043a\u0430 \u0437\u043c\u0443\u0448\u0443\u0454 \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Entity Framework Core \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u0438 \u0432 \u0411\u0414 \u0434\u0430\u043d\u0456 <strong>Product<\/strong> \u0456 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0437 \u043d\u0438\u043c\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 Category. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0438, \u044f\u043a \u0432\u0456\u043d \u0442\u0440\u0430\u043d\u0441\u043b\u044e\u0454\u0442\u044c\u0441\u044f \u0432 SQL-\u0437\u0430\u043f\u0438\u0442, \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u0443\u0432\u0448\u0438 \u0437\u0433\u0435\u043d\u0435\u0440\u043e\u0432\u0430\u043d\u0456 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u043c \u0436\u0443\u0440\u043d\u0430\u043b\u044c\u043d\u0456 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f:<\/p>\n<pre class=\"lang:default decode:true \">SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[PurchasePrice], [p].[RetailPrice], [c].[Id], [c].[Description], [c].[Name]\r\nFROM [Products] AS [p]\r\nINNER JOIN [Categories] AS [c] ON [p].[CategoryId] = [c].[Id]\r\n<\/pre>\n<p>\u0406\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454 \u0437\u043e\u0432\u043d\u0456\u0448\u043d\u0456\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0442\u0443 \u0434\u0430\u043d\u0438\u0445, \u044f\u043a\u0456 \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u0456 \u0434\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 <strong>Category<\/strong>, \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u0445 \u0437 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 Product, \u0456 \u0437\u0430\u0441\u0442\u043e\u0441\u043e\u0432\u0443\u0454 \u0432\u043d\u0443\u0442\u0440\u0456\u0448\u043d\u0454 \u0437&#8217;\u0454\u0434\u043d\u0430\u043d\u043d\u044f \u0434\u043b\u044f \u043e\u0431&#8217;\u0454\u0434\u043d\u0430\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445 \u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044c Products \u0456 Categories.<\/p>\n<p>P.S. \u042f\u043a\u0449\u043e \u0432\u0438 \u0432\u0438\u0434\u0430\u043b\u0438\u0442\u0435 \u043e\u0431&#8217;\u0454\u043a\u0442 Category, \u0442\u043e \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0437 \u043d\u0438\u043c \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 Product, \u0442\u0430\u043a\u043e\u0436 \u0432\u0438\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f, \u0449\u043e \u0454 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u044e \u043a\u043e\u043d\u0444\u0456\u0433\u0443\u0440\u0430\u0446\u0456\u0454\u044e \u0434\u043b\u044f \u043e\u0431\u043e\u0432&#8217;\u044f\u0437\u043a\u043e\u0432\u0438\u0445 \u0432\u0456\u0434\u043d\u043e\u0441\u0438\u043d.<\/p>\n<h2 id=\"addingorder\">\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043f\u0456\u0434\u0442\u0440\u0438\u043c\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c<\/h2>\n<p>\u0429\u043e\u0431 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0443\u0432\u0430\u0442\u0438 \u0431\u0456\u043b\u044c\u0448 \u0441\u043a\u043b\u0430\u0434\u043d\u0435 \u0432\u0456\u0434\u043d\u043e\u0448\u0435\u043d\u043d\u044f, \u043c\u0438 \u0434\u043e\u0434\u0430\u043c\u043e \u043f\u0456\u0434\u0442\u0440\u0438\u043c\u043a\u0443 \u0434\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0456 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c \u0456 \u0431\u0443\u0434\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u0457\u0445 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u0438\u0431\u043e\u0440\u0443 \u0442\u043e\u0432\u0430\u0440\u0456\u0432, \u0437\u0440\u043e\u0431\u043b\u0435\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u0443\u043f\u0446\u044f\u043c\u0438. \u0423 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0445 \u0440\u043e\u0437\u0434\u0456\u043b\u0430\u0445 \u043c\u0438 \u0440\u043e\u0437\u0448\u0438\u0440\u0438\u043c\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0438\u043c\u0438 \u043c\u0430\u0441\u0430\u043c\u0438, \u043e\u043d\u043e\u0432\u0438\u043c\u043e \u0411\u0414 \u0456 \u0434\u043e\u0434\u0430\u043c\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0456\u043d\u043d\u044f \u043d\u043e\u0432\u0438\u043c\u0438 \u0434\u0430\u043d\u0438\u043c\u0438.<\/p>\n<h3>\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043b\u0430\u0441\u0456\u0432 \u043c\u043e\u0434\u0435\u043b\u0456 \u0434\u0430\u043d\u0438\u0445<\/h3>\n<p>\u041f\u043e\u0447\u043d\u0435\u043c\u043e \u0437 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Models<\/strong> \u0444\u0430\u0439\u043b\u0443 \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>Order.cs<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public class Order\r\n    {\r\n        public int Id { get; set; }\r\n        public string CustomerName { get; set; }\r\n        public string Address { get; set; }\r\n        public string State { get; set; }\r\n        public string ZipCode { get; set; }\r\n        public bool Shipped { get; set; }\r\n\r\n        public IEnumerable&lt;OrderLine&gt; Lines { get; set; }\r\n    }\r\n<\/pre>\n<p>\u041a\u043b\u0430\u0441 Order \u043c\u0430\u0454 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456, \u044f\u043a\u0456 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u044e\u0442\u044c \u0456\u043c&#8217;\u044f \u0442\u0430 \u0430\u0434\u0440\u0435\u0441\u0443 \u043f\u043e\u043a\u0443\u043f\u0446\u044f, \u0430 \u0442\u0430\u043a\u043e\u0436 \u043e\u0437\u043d\u0430\u043a\u0443, \u0447\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0456 \u0442\u043e\u0432\u0430\u0440\u0438. \u0404 \u0442\u0430\u043a\u043e\u0436 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0439\u043d\u0430 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c, \u0449\u043e \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0443\u0454 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 OrderLine, \u044f\u043a\u0456 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u0438\u043c\u0443\u0442\u044c \u043e\u043a\u0440\u0435\u043c\u0456 \u0432\u0438\u0431\u0440\u0430\u043d\u0456 \u0442\u043e\u0432\u0430\u0440\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043b\u0430\u0441\u0443 <strong>OrderLine<\/strong> \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Models<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f<strong> OrderLine.cs<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public class OrderLine\r\n    {\r\n        public int Id { get; set; }\r\n        public int ProductId { get; set; }\r\n        public int OrderId { get; set; }\r\n        \r\n        public int Quantity { get; set; }\r\n\t\r\n        public Product Product { get; set; }\r\n        public Order Order { get; set; }\r\n    }\r\n<\/pre>\n<p>\u041a\u043e\u0436\u0435\u043d \u043e\u0431&#8217;\u0454\u043a\u0442 <strong>OrderLine<\/strong> \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u0439 \u0437 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 <strong>Order<\/strong> \u0456 <strong>Product<\/strong> \u0456 \u043c\u0430\u0454 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c, \u044f\u043a\u0430 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0454, \u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u0443 \u043f\u043e\u043a\u0443\u043f\u0435\u0446\u044c \u0437\u0430\u043c\u043e\u0432\u0438\u0432. \u0429\u043e\u0431 \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0438\u0442\u0438 \u0437\u0440\u0443\u0447\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u0434\u0430\u043d\u0438\u0445 <strong>Order<\/strong>, \u0434\u043e\u0434\u0430\u043c\u043e \u0432 \u043a\u043b\u0430\u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 <strong>ApplicationContext<\/strong> \u0442\u0430\u043a\u0456 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456:<\/p>\n<pre class=\"lang:default decode:true \">public class ApplicationContext : DbContext\r\n    {\r\n        public ApplicationContext(DbContextOptions&lt;ApplicationContext&gt; context) : base(context)\r\n        {\r\n\r\n        }\r\n        public DbSet&lt;Product&gt; Products { get; set; }\r\n        public DbSet&lt;Category&gt; Categories { get; set; }\r\n\r\n        public DbSet&lt;Order&gt; Orders { get; set; }\r\n        public DbSet&lt;OrderLine&gt; OrderLines { get; set; }\r\n    }\r\n<\/pre>\n<h2 id=\"createrepository\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0456 \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0434\u0430\u043d\u043d\u044f \u0443\u0437\u0433\u043e\u0434\u0436\u0435\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u0434\u043e \u043d\u043e\u0432\u0438\u0445 \u0434\u0430\u043d\u0438\u0445 \u0440\u0435\u0448\u0442\u0456 \u043a\u043e\u0434\u0443 \u0434\u043e\u0434\u0430\u0442\u043a\u0430 \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Interfaces<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>IOrder.cs<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public interface IOrder\r\n    {\r\n        IEnumerable&lt;Order&gt; GetAllOrders();\r\n        Order GetOrder(int id);\r\n        void AddOrder(Order order);\r\n        void UpdateOrder(Order order);\r\n        void DeleteOrder(Order order);\r\n    }\r\n<\/pre>\n<p>\u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Repository<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>OrderRepository.cs<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public class OrderRepository : IOrder\r\n    {\r\n        private ApplicationContext _context;\r\n\r\n        public OrderRepository(ApplicationContext context)\r\n        {\r\n            _context = context;\r\n        }\r\n\r\n        public IEnumerable&lt;Order&gt; GetAllOrders()\r\n        {\r\n            return _context.Orders.Include(e =&gt; e.Lines).ThenInclude(e =&gt; e.Product);\r\n        }\r\n\r\n        public Order GetOrder(int id)\r\n        {\r\n            return _context.Orders.Include(e =&gt; e.Lines).FirstOrDefault(e =&gt; e.Id == id);\r\n        }\r\n\r\n        public void AddOrder(Order order)\r\n        {\r\n            _context.Orders.Add(order);\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void DeleteOrder(Order order)\r\n        {\r\n            _context.Orders.Remove(order);\r\n            _context.SaveChanges();\r\n        }\r\n\r\n        public void UpdateOrder(Order order)\r\n        {\r\n            _context.Orders.Update(order);\r\n            _context.SaveChanges();\r\n        }\r\n    }\r\n<\/pre>\n<p>\u0420\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u044f \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0441\u043b\u0456\u0434\u0443\u0454 \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u043f\u0440\u0438\u0439\u043d\u044f\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0456\u043d\u0448\u0438\u0445 \u0441\u0445\u043e\u0432\u0438\u0449, \u0456 \u0437\u0430\u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0438 \u043d\u0435 \u0437\u0430\u0434\u0456\u044e\u0454 \u0437\u0430\u0441\u0456\u0431 \u0432\u0438\u044f\u0432\u043b\u0435\u043d\u043d\u044f \u0437\u043c\u0456\u043d. \u0417\u0432\u0435\u0440\u043d\u0456\u0442\u044c \u0443\u0432\u0430\u0433\u0443 \u043d\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u043c\u0435\u0442\u043e\u0434\u0456\u0432 <strong>Include()<\/strong> \u0456 <strong>Theninclude()<\/strong> \u0434\u043b\u044f \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0457 \u043c\u043e\u0434\u0435\u043b\u043b\u044e \u0434\u0430\u043d\u0438\u0445 \u0456 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432 \u0437\u0430\u043f\u0438\u0442\u0438 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0438\u0445 \u0434\u0430\u043d\u0438\u0445.<\/p>\n<p>\u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043a\u043b\u0430\u0441 <strong>Program<\/strong> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0449\u043e\u0431 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u043f\u0440\u043e\u0432\u0430\u0434\u0436\u0435\u043d\u043d\u044f \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u043e\u0437\u043f\u0456\u0437\u043d\u0430\u0432\u0430\u043b\u0430 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0456 \u0432\u0456\u0434 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 <strong>IOrderRepository<\/strong> \u0437 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0447\u0430\u0441\u043d\u0438\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 <strong>OrderRepository<\/strong>:<\/p>\n<pre class=\"lang:default decode:true \">builder.Services.AddTransient&lt;IOrder, OrderRepository&gt;();<\/pre>\n<h2 id=\"addmigarionanduse\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0442\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457<\/h2>\n<p>\u0406\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u043d\u0435 \u0437\u043c\u043e\u0436\u0435 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0442\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 <strong>Order<\/strong> \u0434\u043e\u0442\u0438, \u0434\u043e\u043a\u0438 \u0411\u0414 \u043d\u0435 \u0431\u0443\u0434\u0435 \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0434\u043b\u044f \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e\u0441\u0442\u0456 \u0437\u043c\u0456\u043d\u0430\u043c, \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u043c \u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445. \u0429\u043e\u0431 \u043e\u043d\u043e\u0432\u0438\u0442\u0438 \u0411\u0414, \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u0456 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0434\u043e \u043d\u0435\u0457 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u044e.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457 \u0443 \u0432\u0456\u043a\u043d\u0456 <strong>Package Manager Console<\/strong> \u0432\u0432\u0435\u0434\u0456\u0442\u044c \u0442\u0430\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre class=\"lang:default decode:true \">Add-Migration AddOrders<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-227 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/6-1.png\" alt=\"migration ef c#\" width=\"463\" height=\"205\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/6-1.png 463w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/6-1-300x133.png 300w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/p>\n<p>\u0414\u043b\u044f \u0432\u0438\u043a\u043e\u043d\u0430\u043d\u043d\u044f \u0456\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0456\u0439 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0457, \u0443 \u0432\u0456\u043a\u043d\u0456 <strong>Package Manager Console<\/strong> \u0432\u0438\u043a\u043e\u043d\u0430\u0439\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre class=\"lang:default decode:true \">Update-Database<\/pre>\n<p>\u041f\u0435\u0440\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0432\u043e\u0440\u044e\u0454 \u043d\u043e\u0432\u0443 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u044e \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>Orders<\/strong>, \u044f\u043a\u0430 \u043c\u0456\u0441\u0442\u0438\u0442\u0438\u043c\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0438, \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u0456 \u0434\u043b\u044f \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0411\u0414 \u0434\u043e \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u043d\u043d\u044f \u043d\u043e\u0432\u0438\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432. \u0414\u0440\u0443\u0433\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u0438\u043a\u043e\u043d\u0443\u0454 \u0442\u0430\u043a\u0456 \u043a\u043e\u043c\u0430\u043d\u0434\u0438 \u0434\u043b\u044f \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0411\u0414.<\/p>\n<p>\u041f\u043e\u0442\u043e\u0447\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u0441\u0442\u043e\u0441\u043e\u0432\u0430\u043d\u0438\u0445 \u043c\u0456\u0433\u0440\u0430\u0446\u0456\u0439:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-228 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/7-1.png\" alt=\"migration history\" width=\"269\" height=\"98\" \/><\/p>\n<p>\u041f\u043e\u0442\u043e\u0447\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0454\u043a\u0442\u0443:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-229 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/8-1.png\" alt=\"asp.net core project structure\" width=\"401\" height=\"754\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/8-1.png 401w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/8-1-160x300.png 160w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/p>\n<h2 id=\"addviews\">\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0456\u0432 \u0456 \u0443\u044f\u0432\u043b\u0435\u043d\u044c<\/h2>\n<p>\u0423\u0432\u0435\u0441\u044c \u0441\u043f\u043e\u043b\u0443\u0447\u043d\u0438\u0439 \u043a\u043e\u0434 Entity Framework Core \u0434\u043b\u044f \u0440\u043e\u0431\u043e\u0442\u0438 \u0437 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 <strong>Order<\/strong> \u043d\u0430 \u043c\u0456\u0441\u0446\u0456; \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u043a\u0440\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0431\u0430\u0447\u0430\u0454 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0437\u0430\u0441\u043e\u0431\u0456\u0432 <strong>MVC<\/strong>, \u0449\u043e \u0434\u0430\u0434\u0443\u0442\u044c \u0437\u043c\u043e\u0433\u0443 \u0441\u0442\u0432\u043e\u0440\u044e\u0432\u0430\u0442\u0438 \u0442\u0430 \u043a\u0435\u0440\u0443\u0432\u0430\u0442\u0438 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438. \u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>Controllers<\/strong> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>OrdersController.cs<\/strong>, \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">public class OrdersController : Controller\r\n    {\r\n        private readonly IProduct _products;\r\n        private readonly IOrder _orders;\r\n\r\n        public OrdersController(IProduct products, IOrder orders)\r\n        {\r\n            _products = products;\r\n            _orders = orders;\r\n        }\r\n        public IActionResult Index()\r\n        {\r\n            return View(_orders.GetAllOrders());\r\n        }\r\n        public IActionResult EditOrder(int id)\r\n        {\r\n            var products = _products.GetAllProducts();\r\n            Order order = id == 0 ? new Order() : _orders.GetOrder(id);\r\n            IDictionary&lt;int, OrderLine&gt; lineMaps = order.Lines?.ToDictionary(e =&gt; e.ProductId) ?? new Dictionary&lt;int, OrderLine&gt;();\r\n            ViewBag.Lines = products.Select(e =&gt; lineMaps.ContainsKey(e.Id) ? lineMaps[e.Id] : new OrderLine\r\n            {\r\n                Product = e,\r\n                ProductId = e.Id,\r\n                Quantity = 0\r\n            });\r\n            return View(order);\r\n        }\r\n        [HttpPost]\r\n        public IActionResult AddOrUpdateOrder(Order order)\r\n        {\r\n            \/\/\u0412\u0441\u043a\u043e\u0440\u0435 \u0434\u043e\u043f\u0438\u0448\u0435\u043c...\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n        [HttpPost]\r\n        public IActionResult DeleteOrder(Order order)\r\n        {\r\n           _orders.DeleteOrder(order);\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n    }\r\n<\/pre>\n<p>\u0420\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u044f \u043c\u0435\u0442\u043e\u0434\u0443 <strong>AddOrUpdateOrder()<\/strong> \u0431\u0443\u0434\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u043a\u043e\u043b\u0438 \u0441\u0442\u0430\u043d\u0443\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0438\u043c\u0438 \u0456\u043d\u0448\u0456 \u0437\u0430\u0441\u043e\u0431\u0438.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0438 LINQ \u0443 \u043c\u0435\u0442\u043e\u0434\u0456 \u0434\u0456\u0457 <strong>EditOrder()<\/strong> \u043c\u043e\u0436\u0443\u0442\u044c \u0432\u0438\u0433\u043b\u044f\u0434\u0430\u0442\u0438 \u0437\u0430\u043f\u043b\u0443\u0442\u0430\u043d\u0438\u043c\u0438, \u0430\u043b\u0435 \u0432\u043e\u043d\u0438 \u0437\u0434\u0456\u0439\u0441\u043d\u044e\u044e\u0442\u044c \u043f\u0456\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u0438\u0445 OrderLine, \u0449\u043e\u0431 \u043c\u0430\u0442\u0438 \u043e\u0434\u0438\u043d \u043e\u0431&#8217;\u0454\u043a\u0442 OrderLine \u0434\u043b\u044f \u043a\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 Product, \u043d\u0430\u0432\u0456\u0442\u044c \u044f\u043a\u0449\u043e \u0440\u0430\u043d\u0456\u0448\u0435 \u0446\u0435\u0439 \u0442\u043e\u0432\u0430\u0440 \u043d\u0435 \u0432\u0438\u0431\u0438\u0440\u0430\u0432\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0447\u0438\u043d\u043e\u043c, \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c ViewBag.Lines \u0431\u0443\u0434\u0435 \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0442\u0438\u0441\u044f \u043f\u043e\u0441\u043b\u0456\u0434\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 <strong>OrderLine<\/strong>, \u0449\u043e \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0430\u044e\u0442\u044c \u043a\u043e\u0436\u043d\u043e\u043c\u0443 \u043e\u0431&#8217;\u0454\u043a\u0442\u0443 Product \u0443 \u0411\u0414, \u0437\u0456 \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u043c\u0438 \u0432 0 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u044f\u043c\u0438 Id \u0456 <strong>Quantity<\/strong>. \u041a\u043e\u043b\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044c\u0441\u044f \u0432 \u0411\u0414, \u043d\u0443\u043b\u044c\u043e\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f Id \u0432\u043a\u0430\u0437\u0443\u0432\u0430\u0442\u0438\u043c\u0435, \u0449\u043e \u043e\u0431&#8217;\u0454\u043a\u0442 \u0454 \u043d\u043e\u0432\u0438\u043c, \u0456 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0430\u0437 \u0434\u0430\u043d\u0438\u0445 \u043f\u0440\u0438\u0441\u0432\u043e\u0457\u0442\u044c \u0439\u043e\u043c\u0443 \u043d\u043e\u0432\u0438\u0439 \u0443\u043d\u0456\u043a\u0430\u043b\u044c\u043d\u0438\u0439 \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u0438\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u044f\u0432\u043d\u0438\u0445 \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c <strong>ViewBag.Lines<\/strong> \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0442\u0438\u043c\u0435\u0442\u044c\u0441\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 OrderLine, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u0438\u043c\u0438 \u0437 \u0411\u0414, \u0456 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0438\u043c\u0438 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 \u0437 \u043d\u0443\u043b\u044c\u043e\u0432\u0438\u043c\u0438 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u044f\u043c\u0438 Id \u0434\u043b\u044f \u0440\u0435\u0448\u0442\u0438 \u0442\u043e\u0432\u0430\u0440\u0456\u0432.<\/p>\n<p>\u0414\u0430\u043b\u0456 \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u043f\u043e\u0434\u0430\u043d\u043d\u044f, \u044f\u043a\u0435 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u0438\u043c\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0456\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 \u0443 \u0411\u0414. \u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 <strong>Views\/Orderers<\/strong> \u0456 \u043f\u043e\u043c\u0456\u0441\u0442\u0456\u0442\u044c \u0443 \u043d\u0435\u0457 \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f<strong> Index.cshtml<\/strong> \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0412\u0441\u0435 \u0437\u0430\u043a\u0430\u0437\u044b\";\r\n}\r\n@model IEnumerable&lt;Order&gt;\r\n\r\n&lt;h3 class=\"p-2 bg-primary text-white text-center\"&gt;\u0417\u0430\u043a\u0430\u0437\u044b&lt;\/h3&gt;\r\n&lt;div class=\"container-fluid mt-3\"&gt;\r\n    &lt;div class=\"row\"&gt;\r\n        &lt;div class=\"col-1 fw-bold\"&gt;Id&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;Zip&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0412\u0441\u0435\u0433\u043e&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0421\u0443\u043c\u043c\u0430&lt;\/div&gt;\r\n        &lt;div class=\"col fw-bold\"&gt;\u0421\u0442\u0430\u0442\u0443\u0441&lt;\/div&gt;\r\n        &lt;div class=\"col-3\"&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div&gt;\r\n\r\n    @foreach (Order order in Model)\r\n    {\r\n        &lt;div class=\"row p-2\"&gt;\r\n            &lt;div class=\"col-1\"&gt;@order.Id&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@order.CustomerName&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@order.ZipCode&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@order.Lines.Sum(e=&gt;e.Quantity * e.Product.RetailPrice - e.Product.PurchasePrice)&lt;\/div&gt;\r\n            &lt;div class=\"col\"&gt;@(order.Shipped ? \"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\" : \"\u041e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430\")&lt;\/div&gt;\r\n            &lt;div class=\"col-3 text-right\"&gt;\r\n                &lt;form asp-action=\"DeleteOrder\" method=\"post\"&gt;\r\n                    &lt;input type=\"hidden\" name=\"Id\" value=\"@order.Id\"&gt;\r\n                    &lt;a asp-action=\"EditOrder\" asp-route-id=\"@order.Id\" class=\"btn btn-outline-primary\"&gt;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&lt;\/a&gt;\r\n                    &lt;button type=\"submit\" class=\"btn btn-outline-danger\"&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c&lt;\/button&gt;\r\n                &lt;\/form&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    }\r\n&lt;\/div&gt;\r\n&lt;div class=\"text-center\"&gt;\r\n    &lt;a asp-action=\"EditOrder\" class=\"btn btn-primary\"&gt;\u0421\u043e\u0437\u0434\u0430\u0442\u044c&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u041f\u043e\u0434\u0430\u043d\u043d\u044f \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0454 \u0437\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u043f\u043e \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u0445 <strong>Order<\/strong> \u0437 \u0411\u0414, \u0430 \u0442\u0430\u043a\u043e\u0436 \u0441\u0443\u043c\u0430\u0440\u043d\u0443 \u0432\u0430\u0440\u0442\u0456\u0441\u0442\u044c \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u0438\u0445 \u0442\u043e\u0432\u0430\u0440\u0456\u0432 \u0456 \u0440\u043e\u0437\u043c\u0456\u0440 \u043f\u0440\u0438\u0431\u0443\u0442\u043a\u0443, \u044f\u043a\u0438\u0439 \u0431\u0443\u0434\u0435 \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043e. \u0422\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u043d\u0456 \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0456 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u043d\u0430\u044f\u0432\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f.<\/p>\n<p>\u0429\u043e\u0431 \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0438\u0442\u0438 \u0434\u043e\u0434\u0430\u0442\u043e\u043a \u043f\u043e\u0434\u0430\u043d\u043d\u044f\u043c \u0434\u043b\u044f \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0430\u0431\u043e \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f, \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443<strong> Views\/Orderers<\/strong> \u0444\u0430\u0439\u043b \u043d\u0430 \u0456\u043c&#8217;\u044f <strong>EditOrder.cshtml<\/strong>, \u0437 \u0442\u0430\u043a\u0438\u043c \u0432\u043c\u0456\u0441\u0442\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">@{\r\n    ViewData[\"Title\"] = \"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430\";\r\n}\r\n@model Order\r\n\r\n&lt;div class=\"p-5 text-center bg-light\"&gt;\r\n    &lt;h2 class=\"mb-3\"&gt;\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0430&lt;\/h2&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;form asp-action=\"AddOrUpdateOrder\" method=\"post\"&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"Id\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"Id\" class=\"form-control\" readonly=\"readonly\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"CustomerName\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"CustomerName\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"Address\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"Address\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"State\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"State\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;label asp-for=\"ZipCode\"&gt;&lt;\/label&gt;\r\n        &lt;input asp-for=\"ZipCode\" class=\"form-control\" \/&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-check\"&gt;\r\n        &lt;label class=\"form-check-label\"&gt;\r\n            &lt;input type=\"checkbox\" asp-for=\"Shipped\" class=\"form-check-input\" \/&gt;\r\n            \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\r\n        &lt;\/label&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;h6 class=\"mt-1 \u0440-2 bg-primary text-white text-center\"&gt;\r\n        \u0417\u0430\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u0432\u0430\u0440\u044b\r\n    &lt;\/h6&gt;\r\n    &lt;div class=\"container-fluid\"&gt;\r\n        &lt;div class=\"row\"&gt;\r\n            &lt;div class=\"col font-weight-bold\"&gt;\u0422\u043e\u0432\u0430\u0440&lt;\/div&gt;\r\n            &lt;div class=\"col font-weight-bold\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f&lt;\/div&gt;\r\n            &lt;div class=\"col font-weight-bold\"&gt;\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e&lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        @{\r\n            int counter = 0;\r\n        }\r\n        @foreach (OrderLine line in ViewBag.Lines)\r\n        {\r\n            &lt;input type=\"hidden\" name=\"lines[@counter].Id\" value=\"@line.Id\" \/&gt;\r\n            &lt;input type=\"hidden\" name=\"lines[@counter].ProductId\" value=\"@line.ProductId\" \/&gt;\r\n            &lt;input type=\"hidden\" name=\"lines[@counter].OrderId\" value=\"@line.OrderId\" \/&gt;\r\n            &lt;div class=\"row mt-1\"&gt;\r\n                &lt;div class=\"col\"&gt;@line.Product.Name&lt;\/div&gt;\r\n                &lt;div class=\"col\"&gt;@line.Product.Category.Name&lt;\/div&gt;\r\n                &lt;div class=\"col\"&gt;\r\n                    &lt;input type=\"number\" name=\"lines[@counter].Quantity\" value=\"@line.Quantity\" \/&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n            counter++;\r\n        }\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group text-center\"&gt;\r\n        &lt;button class=\"btn btn-primary\" type=\"submit\"&gt;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/button&gt;\r\n        &lt;a asp-action=\"Index\" class=\"btn btn-secondary\"&gt;\u041e\u0442\u043c\u0435\u043d\u0430&lt;\/a&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<p>\u041f\u043e\u0434\u0430\u043d\u043d\u044f <strong>EditOrder<\/strong> \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0435\u0432\u0456 \u0444\u043e\u0440\u043c\u0443 \u0437 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 input \u0434\u043b\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0435\u0439, \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0445 \u0443 \u043a\u043b\u0430\u0441\u0456 <strong>Order<\/strong>, \u0456 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0456\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 <strong>Product<\/strong> \u0443 \u0411\u0414, \u044f\u043a\u0456 \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0432\u0430\u0442\u0438\u043c\u0443\u0442\u044c\u0441\u044f \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043e\u044e \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044e \u043f\u0456\u0434 \u0447\u0430\u0441 \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043d\u043d\u044f \u043d\u0430\u044f\u0432\u043d\u0438\u0445 \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0435\u0433\u0448\u0435\u043d\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u0434\u043e \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u044c, \u0434\u043e\u0434\u0430\u043c\u043e \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u0432 \u043c\u0435\u043d\u044e, \u0434\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u0437\u043c\u0456\u043d\u0438\u043c\u043e \u0432\u043c\u0456\u0441\u0442 <strong>Views \/ Shared \/ _Layout.cshtml<\/strong>, \u0442\u0430\u043a\u0438\u043c \u0447\u0438\u043d\u043e\u043c:<\/p>\n<pre class=\"lang:default decode:true \">\/\/...\r\n                &lt;div class=\"navbar-collapse collapse d-sm-inline-flex justify-content-between\"&gt;\r\n                    &lt;ul class=\"navbar-nav flex-grow-1\"&gt;\r\n                        &lt;li class=\"nav-item\"&gt;\r\n                            &lt;a class=\"nav-link text-dark\" asp-area=\"\" asp-controller=\"Home\" asp-action=\"Index\"&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt;\r\n                        &lt;\/li&gt;\r\n                        &lt;li class=\"nav-item\"&gt;\r\n                            &lt;a class=\"nav-link text-dark\" asp-area=\"\" asp-controller=\"Categories\" asp-action=\"Index\"&gt;\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438&lt;\/a&gt;\r\n                        &lt;\/li&gt;\r\n                        &lt;li class=\"nav-item\"&gt;\r\n                            &lt;a class=\"nav-link text-dark\" asp-area=\"\" asp-controller=\"Orders\" asp-action=\"Index\"&gt;\u0417\u0430\u043a\u0430\u0437\u044b&lt;\/a&gt;\r\n                        &lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0456\u0442\u044c \u0434\u043e\u0434\u0430\u0442\u043e\u043a, \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0439\u0442\u0435\u0441\u044f, \u0449\u043e \u0444\u043e\u0440\u043c\u0430 \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0454\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u0435\u043a\u0442\u043d\u043e:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-231 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/9-1.png\" alt=\"asp.net core mvc orders\" width=\"992\" height=\"917\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/9-1.png 992w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/9-1-300x277.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/9-1-768x710.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<h2 id=\"savingordersdata\">\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445 \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f<\/h2>\n<p>\u041a\u043b\u0430\u0446\u0430\u043d\u043d\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u0446\u0456 <strong>\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438<\/strong> \u043d\u0435 \u043f\u0440\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u043e \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0431\u0443\u0434\u044c-\u044f\u043a\u0438\u0445 \u0434\u0430\u043d\u0438\u0445, \u0442\u043e\u043c\u0443 \u0449\u043e \u043c\u0435\u0442\u043e\u0434 <strong>AddOrUpdateOrder()<\/strong> \u0437\u0430\u043b\u0438\u0448\u0438\u0432\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u043c. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c\u043e \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 <strong>Orders<\/strong> \u0456 \u0434\u043e\u043f\u0438\u0448\u0435\u043c\u043e \u0446\u0435\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre class=\"lang:default decode:true \">public class OrdersController : Controller\r\n    {\r\n\r\n        \/\/...\r\n        [HttpPost]\r\n        public IActionResult AddOrUpdateOrder(Order order)\r\n        {\r\n            order.Lines = order.Lines.Where(e =&gt; e.Id &gt; 0 || (e.Id == 0 &amp;&amp; e.Quantity &gt; 0)).ToArray();\r\n            if (order.Id == 0)\r\n            {\r\n                _orders.AddOrder(order);\r\n            }\r\n            else\r\n            {\r\n                _orders.UpdateOrder(order);\r\n            }\r\n            return RedirectToAction(nameof(Index));\r\n        }\r\n    }\r\n<\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0456 \u0434\u0456\u0457 \u043f\u043e\u043a\u043b\u0430\u0434\u0430\u044e\u0442\u044c\u0441\u044f \u043d\u0430 \u0437\u0440\u0443\u0447\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0456\u043e\u043d\u0430\u043b\u044c\u043d\u0443 \u043e\u0441\u043e\u0431\u043b\u0438\u0432\u0456\u0441\u0442\u044c Entity Framework Core: \u0443 \u0440\u0430\u0437\u0456 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 Order \u043c\u0435\u0442\u043e\u0434\u0443 <strong>AddOrder()<\/strong> \u0430\u0431\u043e <strong>UpdateOrder()<\/strong> \u0441\u0445\u043e\u0432\u0438\u0449\u0430 \u0456\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Entity Framework Core \u0437\u0431\u0435\u0440\u0435\u0436\u0435 \u043d\u0435 \u0442\u0456\u043b\u044c\u043a\u0438 \u0446\u0435\u0439 \u043e\u0431&#8217;\u0454\u043a\u0442 <strong>Order<\/strong>, \u0430 \u0439 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0437 \u043d\u0438\u043c \u043e\u0431&#8217;\u0454\u043a\u0442\u0438 OrderLine. \u0417\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043e\u0441\u043e\u0431\u043b\u0438\u0432\u0456\u0441\u0442\u044c \u043c\u043e\u0436\u0435 \u043d\u0435 \u0432\u0438\u0433\u043b\u044f\u0434\u0430\u0442\u0438 \u0432\u0430\u0436\u043b\u0438\u0432\u043e\u044e, \u0430\u043b\u0435 \u0432\u043e\u043d\u0430 \u0441\u043f\u0440\u043e\u0449\u0443\u0454 \u043f\u0440\u043e\u0446\u0435\u0441, \u044f\u043a\u0438\u0439 \u0456\u043d\u0430\u043a\u0448\u0435 \u0432\u0438\u043c\u0430\u0433\u0430\u0432 \u043f\u043e\u0441\u043b\u0456\u0434\u043e\u0432\u043d\u043e\u0441\u0442\u0456 \u0440\u0435\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u043e\u0432\u0430\u043d\u0438\u0445 \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u044c.<\/p>\n<p>\u0429\u043e\u0431 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u0443\u0442\u0438 SQL-\u043a\u043e\u043c\u0430\u043d\u0434\u0438, \u0449\u043e \u0433\u0435\u043d\u0435\u0440\u0443\u044e\u0442\u044c\u0441\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0456\u0442\u044c \u0434\u043e\u0434\u0430\u0442\u043e\u043a \u0456 \u0432\u0438\u043a\u043e\u043d\u0430\u0439\u0442\u0435 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f, \u0437 2-3-\u043c\u0430 \u0442\u043e\u0432\u0430\u0440\u0430\u043c\u0438:<\/p>\n<pre class=\"lang:default decode:true \">INSERT INTO[Orders] ([Address], [CustomerName], [Shipped], [State], [ZipCode])\r\nVALUES(@p0, @p1, @p2, @p3, @p4);\r\nSELECT[Id]\r\nFROM[Orders]\r\nWHERE @@ROWCOUNT = 1 AND[Id] = scope_identity();\r\n\r\nINSERT INTO[OrderLines] ([OrderId], [ProductId], [Quantity])\r\nVALUES(@p0, @p1, @p2);\r\nSELECT[Id]\r\nFROM[OrderLines]\r\nWHERE @@ROWCOUNT = 1 AND[Id] = scope_identity();\r\n<\/pre>\n<p>\u041f\u0435\u0440\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0454 \u043e\u0431&#8217;\u0454\u043a\u0442 Order, \u0430 \u0434\u0440\u0443\u0433\u0430 \u043e\u0442\u0440\u0438\u043c\u0443\u0454 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f, \u043f\u0440\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0435 \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443. \u0414\u0430\u043b\u0456 EF \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0432\u0438\u043d\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043e\u0431&#8217;\u0454\u043a\u0442\u0430 <strong>Order<\/strong> \u0434\u043b\u044f \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432 <strong>OrderLine<\/strong>.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043d\u043d\u0456\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u044f\u043a\u0438\u0439 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0456\u0434\u0437\u043d\u0430\u0447\u0438\u0442\u0438, \u0441\u0442\u043e\u0441\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<pre class=\"lang:default decode:true \">order.Lines = order.Lines.Where(e =&gt; e.Id &gt; 0 || (e.Id == 0 &amp;&amp; e.Quantity &gt; 0)).ToArray();<\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0438\u043a\u043b\u044e\u0447\u0430\u0454 \u0431\u0443\u0434\u044c-\u044f\u043a\u0438\u0439 \u043e\u0431&#8217;\u0454\u043a\u0442 <strong>OrderLine<\/strong>, \u0434\u043b\u044f \u044f\u043a\u043e\u0433\u043e \u043d\u0435 \u0431\u0443\u043b\u043e \u0432\u0438\u0431\u0440\u0430\u043d\u043e \u043d\u0435\u043d\u0443\u043b\u044c\u043e\u0432\u0443 \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044c, \u043e\u043a\u0440\u0456\u043c \u043e\u0431&#8217;\u0454\u043a\u0442\u0456\u0432, \u0449\u043e \u0432\u0436\u0435 \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u044e\u0442\u044c\u0441\u044f \u0432 \u0411\u0414. \u0426\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0443\u0454, \u0449\u043e \u0411\u0414 \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u0432\u043d\u0438\u0442\u044c\u0441\u044f \u043e\u0431&#8217;\u0454\u043a\u0442\u0430\u043c\u0438 OrderLine, \u044f\u043a\u0456 \u043d\u0435 \u0454 \u0447\u0430\u0441\u0442\u0438\u043d\u043e\u044e \u044f\u043a\u043e\u0433\u043e\u0441\u044c \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f, \u0430\u043b\u0435 \u0434\u043e\u0437\u0432\u043e\u043b\u044f\u0454 \u0432\u043d\u043e\u0441\u0438\u0442\u0438 \u0437\u043c\u0456\u043d\u0438 \u0432 \u0440\u0430\u043d\u0456\u0448\u0435 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u0456 \u0434\u0430\u043d\u0456.<\/p>\n<p>\u041f\u0456\u0441\u043b\u044f \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u0437\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0437\u0430 \u0437\u0430\u043c\u043e\u0432\u043b\u0435\u043d\u043d\u044f\u043c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-232 aligncenter\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/10.png\" alt=\"asp.net core order details\" width=\"1200\" height=\"782\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/10.png 1200w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/10-300x196.png 300w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/10-1024x667.png 1024w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/10-768x500.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h2 id=\"final\">\u041f\u0456\u0434\u0441\u0443\u043c\u043e\u043a<\/h2>\n<p>\u0423 \u0440\u043e\u0437\u0434\u0456\u043b\u0456 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u0438\u0445 GameStore \u0431\u0443\u043b\u043e \u0440\u043e\u0437\u0448\u0438\u0440\u0435\u043d\u043e \u0437\u0430 \u0440\u0430\u0445\u0443\u043d\u043e\u043a \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043d\u043e\u0432\u0438\u0445 \u043a\u043b\u0430\u0441\u0456\u0432 \u0456 \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0432\u0456\u0434\u043d\u043e\u0441\u0438\u043d \u043c\u0456\u0436 \u043d\u0438\u043c\u0438. \u0412\u0438 \u0434\u0456\u0437\u043d\u0430\u043b\u0438\u0441\u044f, \u044f\u043a \u0437\u0430\u043f\u0438\u0442\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0434\u0430\u043d\u0456, \u044f\u043a\u0438\u043c \u0447\u0438\u043d\u043e\u043c \u0432\u0438\u043a\u043e\u043d\u0443\u0432\u0430\u0442\u0438 \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f. \u0423 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u0440\u043e\u0437\u0434\u0456\u043b\u0456 \u0431\u0443\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u044f\u043a\u0438\u043c \u0447\u0438\u043d\u043e\u043c \u043f\u0440\u0438\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u043d\u0438 MVC \u0456 Entity Framework Core \u0434\u043e \u0440\u043e\u0431\u043e\u0442\u0438 \u0437 \u0432\u0435\u043b\u0438\u043a\u0438\u043c\u0438 \u043e\u0431\u0441\u044f\u0433\u0430\u043c\u0438 \u0434\u0430\u043d\u0438\u0445.<\/p>\n<p>\u041d\u0430 \u0446\u044c\u043e\u043c\u0443 \u0441\u0442\u0430\u0442\u0442\u044f &#8220;\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF&#8221;, \u043f\u0456\u0434\u0456\u0439\u0448\u043b\u0430 \u0434\u043e \u043a\u0456\u043d\u0446\u044f, \u0441\u043f\u043e\u0434\u0456\u0432\u0430\u044e\u0441\u044f \u0432\u0430\u043c \u0431\u0443\u043b\u043e \u0446\u0456\u043a\u0430\u0432\u043e. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0432\u0438\u0445\u0456\u0434\u043d\u0438\u0439 \u043a\u043e\u0434 \u0443 \u043c\u043e\u0454\u043c\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0456\u0457 &#8211;\u00a0<a href=\"https:\/\/github.com\/murzilaka2\/GameStore-Part-3\">Github<\/a>.<\/p>\n<p>\u041f\u043e\u0434\u0456\u043b\u0456\u0442\u044c\u0441\u044f \u0432\u0430\u0448\u0438\u043c \u0434\u043e\u0441\u0432\u0456\u0434\u043e\u043c \u0443 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u044f\u0445, \u044f\u043a\u0438\u0439 \u0431\u0443\u0432 \u0432\u0430\u0448 \u043f\u0435\u0440\u0448\u0438\u0439 \u043f\u0440\u043e\u0454\u043a\u0442, \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF \u0430\u0431\u043e \u0449\u043e\u0441\u044c \u0456\u043d\u0448\u0435?<\/p>\n<p>\u0422\u0430\u043a \u0441\u0430\u043c\u043e \u0432\u0430\u043c \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u0446\u0456\u043a\u0430\u0432\u0430 \u043f\u043e\u043f\u0435\u0440\u0435\u0434\u043d\u044f \u0441\u0442\u0430\u0442\u0442\u044f:<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"ahU5pnsbh8\"><p><a href=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-2\/\">\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 2<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 2&#8221; &#8212; Dijix -  \u0411\u043b\u043e\u0433\" src=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-2\/embed\/#?secret=5aHT8U2Lxm#?secret=ahU5pnsbh8\" data-secret=\"ahU5pnsbh8\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<hr \/>\n<h4><strong>\u0412\u0438 \u0445\u043e\u0447\u0435\u0442\u0435 \u043d\u0430\u0432\u0447\u0438\u0442\u0438\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u0438 \u043a\u043e\u0434 \u043c\u043e\u0432\u043e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0443\u0432\u0430\u043d\u043d\u044f C#?<\/strong><\/h4>\n<p>\u0421\u0442\u0432\u043e\u0440\u044e\u0432\u0430\u0442\u0438 \u0440\u0456\u0437\u043d\u0456 \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u0439\u043d\u0456 \u0441\u0438\u0441\u0442\u0435\u043c\u0438, \u0449\u043e \u0441\u043a\u043b\u0430\u0434\u0430\u044e\u0442\u044c\u0441\u044f \u0437 \u0441\u0430\u0439\u0442\u0456\u0432, \u043c\u043e\u0431\u0456\u043b\u044c\u043d\u0438\u0445 \u043a\u043b\u0456\u0454\u043d\u0442\u0456\u0432, \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u0438\u0445 \u0434\u043e\u0434\u0430\u0442\u043a\u0456\u0432, \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0456\u0432 \u0442\u043e\u0449\u043e.<\/p>\n<p><a href=\"https:\/\/dijix.com.ua\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-94 size-full\" src=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/logog-brand.png\" alt=\"\" width=\"355\" height=\"77\" srcset=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/logog-brand.png 355w, https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/logog-brand-300x65.png 300w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/a><\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044c\u0442\u0435 \u0434\u043e \u043d\u0430\u0441 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 Dijix \u0456 \u043e\u0437\u043d\u0430\u0439\u043e\u043c\u0442\u0435\u0441\u044f \u0437 \u0443\u043c\u043e\u0432\u0430\u043c\u0438 \u043d\u0430\u0432\u0447\u0430\u043d\u043d\u044f, \u043c\u0438 \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u0456\u0437\u0443\u0454\u043c\u043e\u0441\u044f \u0442\u0456\u043b\u044c\u043a\u0438 \u043d\u0430 \u0456\u043d\u0434\u0438\u0432\u0456\u0434\u0443\u0430\u043b\u044c\u043d\u0438\u0445 \u0437\u0430\u043d\u044f\u0442\u0442\u044f\u0445, \u044f\u043a \u0434\u043b\u044f \u043f\u043e\u0447\u0430\u0442\u043a\u0456\u0432\u0446\u0456\u0432, \u0442\u0430\u043a \u0456 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0443\u043d\u0443\u0442\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0456\u0441\u0442\u0456\u0432. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u0438 \u044f\u043a \u043e\u0434\u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u0442\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0430\u0446\u044e\u0432\u0430\u043d\u043d\u044f \u043f\u0438\u0442\u0430\u043d\u043d\u044f, \u0449\u043e \u0432\u0430\u0441 \u0446\u0456\u043a\u0430\u0432\u0438\u0442\u044c, \u0442\u0430\u043a \u0456 \u043a\u0456\u043b\u044c\u043a\u0430, \u0434\u043b\u044f \u0431\u0456\u043b\u044c\u0448 \u0449\u0456\u043b\u044c\u043d\u043e\u0457 \u0440\u043e\u0431\u043e\u0442\u0438. \u0417\u0430\u0432\u0434\u044f\u043a\u0438 \u043e\u0441\u043e\u0431\u0438\u0441\u0442\u043e\u043c\u0443 \u043a\u0430\u0431\u0456\u043d\u0435\u0442\u0443, \u043a\u043e\u0436\u0435\u043d \u0441\u0442\u0443\u0434\u0435\u043d\u0442 \u043f\u0456\u0434\u0432\u0438\u0449\u0438\u0442\u044c \u044f\u043a\u0456\u0441\u0442\u044c \u0441\u0432\u043e\u0433\u043e \u043d\u0430\u0432\u0447\u0430\u043d\u043d\u044f, \u0443 \u0432\u0430\u0448\u043e\u043c\u0443 \u0440\u043e\u0437\u043f\u043e\u0440\u044f\u0434\u0436\u0435\u043d\u043d\u0456:<\/p>\n<ul>\n<li>\u0414\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0456\u0430\u043b\u0443<\/li>\n<li>\u0422\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u0456 \u0441\u0442\u0430\u0442\u0442\u0456<\/li>\n<li>\u0411\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a\u0430 \u043a\u043d\u0438\u0433<\/li>\n<li>\u041e\u043d\u043b\u0430\u0439\u043d \u0442\u0435\u0441\u0442\u0443\u0432\u0430\u043d\u043d\u044f<\/li>\n<li>\u0421\u043f\u0456\u043b\u043a\u0443\u0432\u0430\u043d\u043d\u044f \u0432 \u0437\u0430\u043a\u0440\u0438\u0442\u0438\u0445 \u0433\u0440\u0443\u043f\u0430\u0445<\/li>\n<\/ul>\n<blockquote>\n<p style=\"text-align: right;\"><a href=\"https:\/\/dijix.com.ua\/uk\/\">https:\/\/dijix.com.ua<\/a><\/p>\n<p style=\"text-align: right;\"><a href=\"https:\/\/ms.dijix.com.ua\/\">\u0416\u0438\u0432\u0438 \u0443 \u0441\u0432\u043e\u0454\u043c\u0443 \u0441\u0432\u0456\u0442\u0456, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0443\u0439 \u0443 \u043d\u0430\u0448\u043e\u043c\u0443<\/a>.<\/p>\n<\/blockquote>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 Entity Framework Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\">Continue reading<span class=\"screen-reader-text\">\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":233,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"uk","_original_post":"https:\/\/dijix.com.ua\/blog\/?p=221","footnotes":""},"categories":[8],"tags":[],"class_list":["post-375","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net-core","uk","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.13 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433<\/title>\r\n<meta name=\"description\" content=\"\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 EF Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\" \/>\r\n<meta property=\"og:locale\" content=\"uk_UA\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Dijix - \u0411\u043b\u043e\u0433\" \/>\r\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Dijixs\" \/>\r\n<meta property=\"article:published_time\" content=\"2023-02-03T11:48:09+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2023-02-03T13:30:17+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1.jpg\" \/>\r\n\t<meta property=\"og:image:width\" content=\"609\" \/>\r\n\t<meta property=\"og:image:height\" content=\"471\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\r\n<meta name=\"author\" content=\"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u041f\u0440\u0438\u0431\u043b. \u0447\u0430\u0441 \u0447\u0438\u0442\u0430\u043d\u043d\u044f\" \/>\n\t<meta name=\"twitter:data2\" content=\"25 \u0445\u0432\u0438\u043b\u0438\u043d\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\"},\"author\":{\"name\":\"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/4ce2240cdf3db189e17ca0ff422a0c3d\"},\"headline\":\"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3\",\"datePublished\":\"2023-02-03T11:48:09+00:00\",\"dateModified\":\"2023-02-03T13:30:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\"},\"wordCount\":2476,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/#organization\"},\"articleSection\":[\"Asp.Net Core\"],\"inLanguage\":\"uk\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\",\"url\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\",\"name\":\"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433\",\"isPartOf\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/#website\"},\"datePublished\":\"2023-02-03T11:48:09+00:00\",\"dateModified\":\"2023-02-03T13:30:17+00:00\",\"description\":\"\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 EF Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445.\",\"breadcrumb\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#breadcrumb\"},\"inLanguage\":\"uk\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\/\/dijix.com.ua\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#website\",\"url\":\"https:\/\/dijix.com.ua\/blog\/\",\"name\":\"Dijix - \u0411\u043b\u043e\u0433\",\"description\":\"\ud83d\udc9c\",\"publisher\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dijix.com.ua\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"uk\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#organization\",\"name\":\"Dijix - \u0411\u043b\u043e\u0433\",\"url\":\"https:\/\/dijix.com.ua\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"uk\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/\u0421\u043d\u0438\u043c\u043e\u043a.png\",\"contentUrl\":\"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/\u0421\u043d\u0438\u043c\u043e\u043a.png\",\"width\":159,\"height\":92,\"caption\":\"Dijix - \u0411\u043b\u043e\u0433\"},\"image\":{\"@id\":\"https:\/\/dijix.com.ua\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Dijixs\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/4ce2240cdf3db189e17ca0ff422a0c3d\",\"name\":\"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"uk\",\"@id\":\"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e3e8fa72f5adf168d30934fb574a97a5e812e7d6e2795075f0e7ea19311e3ba9?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e3e8fa72f5adf168d30934fb574a97a5e812e7d6e2795075f0e7ea19311e3ba9?s=96&d=monsterid&r=g\",\"caption\":\"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430\"},\"sameAs\":[\"https:\/\/dijix.com.ua\/blog\"],\"url\":\"https:\/\/dijix.com.ua\/blog\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433","description":"\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 EF Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/","og_locale":"uk_UA","og_type":"article","og_title":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433","og_url":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/","og_site_name":"Dijix - \u0411\u043b\u043e\u0433","article_publisher":"https:\/\/www.facebook.com\/Dijixs","article_published_time":"2023-02-03T11:48:09+00:00","article_modified_time":"2023-02-03T13:30:17+00:00","og_image":[{"width":609,"height":471,"url":"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/09\/1.jpg","type":"image\/jpeg"}],"author":"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430","twitter_card":"summary_large_image","twitter_misc":{"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e":"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430","\u041f\u0440\u0438\u0431\u043b. \u0447\u0430\u0441 \u0447\u0438\u0442\u0430\u043d\u043d\u044f":"25 \u0445\u0432\u0438\u043b\u0438\u043d"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#article","isPartOf":{"@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/"},"author":{"name":"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430","@id":"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/4ce2240cdf3db189e17ca0ff422a0c3d"},"headline":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3","datePublished":"2023-02-03T11:48:09+00:00","dateModified":"2023-02-03T13:30:17+00:00","mainEntityOfPage":{"@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/"},"wordCount":2476,"commentCount":0,"publisher":{"@id":"https:\/\/dijix.com.ua\/blog\/#organization"},"articleSection":["Asp.Net Core"],"inLanguage":"uk","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/","url":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/","name":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3 - Dijix - \u0411\u043b\u043e\u0433","isPartOf":{"@id":"https:\/\/dijix.com.ua\/blog\/#website"},"datePublished":"2023-02-03T11:48:09+00:00","dateModified":"2023-02-03T13:30:17+00:00","description":"\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456, \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core \u0456 EF Core. \u0423 \u0434\u0440\u0443\u0433\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u043c\u0438 \u0434\u043e\u0434\u0430\u043b\u0438 \u0437\u0430\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u0442\u0430 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043d\u044f \u0434\u0430\u043d\u0438\u0445.","breadcrumb":{"@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#breadcrumb"},"inLanguage":"uk","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dijix.com.ua\/blog\/uk\/magazin-na-asp-net-core-mvc-ef-chast-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/dijix.com.ua\/blog\/"},{"@type":"ListItem","position":2,"name":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Asp.Net Core MVC EF. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 3"}]},{"@type":"WebSite","@id":"https:\/\/dijix.com.ua\/blog\/#website","url":"https:\/\/dijix.com.ua\/blog\/","name":"Dijix - \u0411\u043b\u043e\u0433","description":"\ud83d\udc9c","publisher":{"@id":"https:\/\/dijix.com.ua\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dijix.com.ua\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"uk"},{"@type":"Organization","@id":"https:\/\/dijix.com.ua\/blog\/#organization","name":"Dijix - \u0411\u043b\u043e\u0433","url":"https:\/\/dijix.com.ua\/blog\/","logo":{"@type":"ImageObject","inLanguage":"uk","@id":"https:\/\/dijix.com.ua\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/\u0421\u043d\u0438\u043c\u043e\u043a.png","contentUrl":"https:\/\/dijix.com.ua\/blog\/wp-content\/uploads\/2022\/08\/\u0421\u043d\u0438\u043c\u043e\u043a.png","width":159,"height":92,"caption":"Dijix - \u0411\u043b\u043e\u0433"},"image":{"@id":"https:\/\/dijix.com.ua\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Dijixs"]},{"@type":"Person","@id":"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/4ce2240cdf3db189e17ca0ff422a0c3d","name":"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430","image":{"@type":"ImageObject","inLanguage":"uk","@id":"https:\/\/dijix.com.ua\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e3e8fa72f5adf168d30934fb574a97a5e812e7d6e2795075f0e7ea19311e3ba9?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e3e8fa72f5adf168d30934fb574a97a5e812e7d6e2795075f0e7ea19311e3ba9?s=96&d=monsterid&r=g","caption":"\u041b\u0435\u043e\u043d\u0438\u0434 \u041a\u0430\u0440\u0443\u043d\u0430"},"sameAs":["https:\/\/dijix.com.ua\/blog"],"url":"https:\/\/dijix.com.ua\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/posts\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/comments?post=375"}],"version-history":[{"count":2,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/posts\/375\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/posts\/375\/revisions\/383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/media\/233"}],"wp:attachment":[{"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/media?parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/categories?post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dijix.com.ua\/blog\/wp-json\/wp\/v2\/tags?post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}