{"id":326674,"date":"2021-07-19T15:01:06","date_gmt":"2021-07-19T15:01:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326674"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326674","title":{"rendered":"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Web API OData \u0432 ASP.NET Core 3 \u0438 ASP.NET 5 (\u0447\u0430\u0441\u0442\u044c 1). \u0421\u0432\u044f\u0437\u0438 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043e\u0431\u043e\u0440\u043e\u0442\u0430. \u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 LTS \u0432\u0435\u0440\u0441\u0438\u0438 .NET Core 3.1, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0431\u044d\u043a\u044d\u043d\u0434 \u0434\u043b\u044f SPA, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u044f\u0434 Worker Service\u2019\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u0421\u042d\u0414.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431\u0449\u0438\u0445 \u043c\u0430\u0441\u0442\u0435\u0440-\u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0411\u0414 PostgreSQL, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u043b\u0438 \u0441\u0432\u0435\u0436\u0438\u0439 \u043e\u043f\u044b\u0442 \u0438 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f (\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u2013 \u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438) \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0440\u0435\u0448\u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c Web API \u043d\u0430 .NET Core 3.1, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0411\u0414 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ORM, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u043b\u043e\u0436\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u0438 \u043e\u043f\u044b\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 EF Core.  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 API \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432 OData. <\/p>\n<p>\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 API OData \u043d\u0430 .NET Core, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u043d\u0438\u0445 \u0432\u0435\u0441\u044c\u043c\u0430 \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u0430 \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0430\u0432\u0442\u043e\u0440\u044b \u0443\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0432\u0430\u0436\u043d\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b, \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f API OData \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c EF Core. \u041e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0434\u0435\u043b\u0435\u043d\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 \u0441\u0432\u044f\u0437\u0438 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 ASP.NET Core 3.1    <\/h2>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0432 Visual Studio 2019 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 ASP.NET Core Web API. \u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414 Postgres \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b Microsoft.EntityFrameworkCore, Npgsql.EntityFrameworkCore.PostgreSQL, \u0430 \u0442\u0430\u043a\u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043b\u044f Postgres \u043d\u044d\u0439\u043c\u0438\u043d\u0433\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0411\u0414, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442 EFCore.NamingConventions. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 OData \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043a\u0435\u0442 Microsoft.AspNetCore.OData:<\/p>\n<pre><code class=\"xml\">  &lt;ItemGroup&gt;     &lt;PackageReference Include=\"EFCore.NamingConventions\" Version=\"1.1.1\" \/&gt;     &lt;PackageReference Include=\"Microsoft.AspNetCore.OData\" Version=\"7.5.6\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore\" Version=\"3.1.11\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore.Tools\" Version=\"3.1.11\"&gt;       &lt;PrivateAssets&gt;all&lt;\/PrivateAssets&gt;       &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers; buildtransitive&lt;\/IncludeAssets&gt;     &lt;\/PackageReference&gt;     &lt;PackageReference Include=\"Newtonsoft.Json\" Version=\"12.0.3\" \/&gt;     &lt;PackageReference Include=\"Npgsql.EntityFrameworkCore.PostgreSQL\" Version=\"3.1.11\" \/&gt;   &lt;\/ItemGroup&gt;<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c \u0441\u0432\u044f\u0437\u0438 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e EF Core 3.1 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0434\u0432\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430. \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043f\u043e\u0434 .NET Framework, \u043b\u0438\u0431\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 .NET 5.  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0421\u0438\u0441\u0442\u0435\u043c \u0438 \u0428\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432: \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 public class BaseDictionaryEntry {     [Column(Order = 1)]     [Key]     public long Id { get; set; }      public string Name { get; set; }      public string Description { get; set; } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c public class UsingSystem : BaseDictionaryEntry {     public List&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public UsingSystem()     {         UploadTemplates = new List&lt;UploadTemplate&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 public class UploadTemplate : BaseDictionaryEntry {     public string ProcessName { get; set; }      public List&lt;UsingSystem&gt; UsingSystems { get; set; }      public UploadTemplate()     {         UsingSystems = new List&lt;UsingSystem&gt;();     } }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/ \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 public class MyDbContext : DbContext {     public virtual DbSet&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public virtual DbSet&lt;UsingSystem&gt; UsingSystems { get; set; }      public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)         : base(options)     {     }      public MyDbContext()     {     } }<\/code><\/pre>\n<p>Startup.cs \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/ Startup public class Startup {     public IConfiguration Configuration { get; }          public Startup(IConfiguration configuration)     {         Configuration = configuration;     }          public void ConfigureServices(IServiceCollection services)     {         \/\/ \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414         services.AddDbContext&lt;MyDbContext&gt;(options =&gt; options             .UseNpgsql(Configuration.GetValue&lt;string&gt;(\"ConString\"),                 assembly =&gt; assembly.MigrationsAssembly(typeof(MyDbContext).Assembly.FullName))             .UseSnakeCaseNamingConvention());          services.AddControllers();          \/\/ \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c OData         services.AddOData();     }      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)     {         if (env.IsDevelopment())         {             app.UseDeveloperExceptionPage();         }          app.UseRouting();         app.UseAuthorization();         app.UseEndpoints(endpoints =&gt;         {             endpoints.MapControllers();             endpoints.Select().Filter().OrderBy().Count().MaxTop(10).Expand();             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u0438 OData             endpoints.MapODataRoute(\"odata\", \"odata\", GetEdmModel());         });     }      \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 OData     private IEdmModel GetEdmModel()     {         var odataBuilder = new ODataConventionModelBuilder();         odataBuilder.EntitySet&lt;UsingSystem&gt;(\"UsingSystems\");         odataBuilder.EntitySet&lt;UploadTemplate&gt;(\"UploadTemplates\");          return odataBuilder.GetEdmModel();     } }<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<pre><code class=\"cs\">\/\/ \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 public class UsingSystemsController : BaseDictionaryController {     public UsingSystemsController(DbContext dbContext) : base(dbContext)     {     }      [EnableQuery]     public IActionResult Get()     {         return Ok(_dbContext.UsingSystems             .Include(x =&gt; x.UploadTemplates));     }      [EnableQuery]     public IActionResult Get(long key)     {         return Ok(_dbContext.UsingSystems             .Where(x =&gt; x.Id == key)             .Include(x =&gt; x.UploadTemplates));     } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:  <\/p>\n<blockquote>\n<p>System.InvalidOperationException: Unable to determine the relationship represented by navigation property &#8216;UsingSystem.UploadTemplates&#8217; of type &#8216;List&#8217;. Either manually configure the relationship, or ignore this property using the &#8216;[NotMapped]&#8217; attribute or by using &#8216;EntityTypeBuilder.Ignore&#8217; in &#8216;OnModelCreating&#8217;.<\/p>\n<\/blockquote>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e Entity Framework Core \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0435\u043c\u0443 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e \u0441\u0432\u044f\u0437\u044c\u044e \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb \u0434\u043b\u044f .NET Core 3.1 <\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 UsingSystem \u0438 UploadTemplates, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:     <\/p>\n<pre><code class=\"cs\">\/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 public class BaseDictionaryEntry {     [Column(Order = 1)]     [Key]     public long Id { get; set; }      public string Name { get; set; }      public string Description { get; set; } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c public class UsingSystem : BaseDictionaryEntry {     public List&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public UsingSystem()     {         UploadTemplateUsingSystems = new List&lt;UploadTemplateUsingSystem&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 public class UploadTemplate : BaseDictionaryEntry {     public string ProcessName { get; set; }      public List&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public UploadTemplate()     {         UploadTemplateUsingSystems = new List&lt;UploadTemplateUsingSystem&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0438\u0442\u0435\u043c \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 public class UploadTemplateUsingSystem {     public long UploadTemplateId { get; set; }      public UploadTemplate UploadTemplate { get; set; }      public long UsingSystemId { get; set; }      public UsingSystem UsingSystem { get; set; } }  \/\/ \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 public class MyDbContext : DbContext {     public virtual DbSet&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public virtual DbSet&lt;UsingSystem&gt; UsingSystems { get; set; }      public virtual DbSet&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)         : base(options)     {     }      public MyDbContext()     {     }      protected override void OnModelCreating(ModelBuilder modelBuilder)     {         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasKey(x =&gt; new {x.UploadTemplateId, x.UsingSystemId});         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasOne(x =&gt; x.UploadTemplate)             .WithMany(x =&gt; x.UploadTemplateUsingSystems)             .HasForeignKey(x =&gt; x.UploadTemplateId);         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasOne(x =&gt; x.UsingSystem)             .WithMany(x =&gt; x.UploadTemplateUsingSystems)             .HasForeignKey(x =&gt; x.UsingSystemId);     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u0430\u043a \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0440\u0438\u0447\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e UploadTemplateUsingSystem \u0438\u043c\u0435\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u043a\u043b\u044e\u0447, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0438 Edm \u043c\u043e\u0434\u0435\u043b\u0438. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 $expand \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 API. \u041c\u0435\u0442\u043e\u0434 GetEdmModel \u0432 Startup \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">    private IEdmModel GetEdmModel()     {         var odataBuilder = new ODataConventionModelBuilder();         odataBuilder.EntitySet&lt;UsingSystem&gt;(\"UsingSystems\");         odataBuilder.EntitySet&lt;UploadTemplate&gt;(\"UploadTemplates\");         odataBuilder.EntityType&lt;UploadTemplateUsingSystem&gt;()             .HasKey(x =&gt; new {x.UploadTemplateId, x.UsingSystemId});          return odataBuilder.GetEdmModel();     } <\/code><\/pre>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cs\">    [EnableQuery]     public IActionResult Get()     {         return Ok(_dbContext.UsingSystems             .Include(x =&gt; x.UploadTemplateUsingSystems)             .ThenInclude(x =&gt; x.UploadTemplate));     }          [EnableQuery]     public IActionResult Get(long key)     {         return Ok(_dbContext.UsingSystems             .Where(x =&gt; x.Id == key)             .Include(x =&gt; x.UploadTemplateUsingSystems)             .ThenInclude(x =&gt; x.UploadTemplate));     }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0432 \u0431\u0430\u0437\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0435\u0442\u044c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u043b\u044f\u043c\u0438 \u2013 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0430. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u0438\u0437 \u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448\u0435 API \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c $expand \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c: <\/p>\n<p><code>GET http:\/\/localhost:61268\/odata\/UsingSystems(1)?$expand=UploadTemplates<\/code> <\/p>\n<p>OData \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e UploadTemplates \u0432 \u0442\u0438\u043f\u0435 UsingSystem. \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <\/p>\n<p><code>GET http:\/\/localhost:61268\/odata\/UsingSystems(1)?$expand= UploadTemplateUsingSystems($expand=UploadTemplates)<\/code> <\/p>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c JSON \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"json\">{     \"@odata.context\": \"http:\/\/myAPI.com\/odata\/$metadata#UsingSystems(UploadTemplateUsingSystems(UploadTemplate()))\",     \"value\": [         {             \"Id\": 1,             \"Name\": \"\u0421\u0438\u0441\u0442\u0435\u043c\u04301\",             \"Description\": \"\u041f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430\",             \"UploadTemplateUsingSystems\": [                 {                     \"UsingSystemId\": 1,                     \"UploadTemplateId \": 123,                     \"UploadTemplate\": {                         \"Id\": 123,                         \"Name\": \"\u0428\u0430\u0431\u043b\u043e\u043d1\",                         \"Description\": \"\u041f\u0440\u043e\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\",                         \"ProcessName\": \"\u041f\u0440\u043e\u0446\u0435\u0441\u04411\"                     }                 }             ]         }     ] } <\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b, \u0434\u0430 \u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432 API.<\/p>\n<h2>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e .NET 5<\/h2>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u043d\u0430 .NET 5. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"xml\">  &lt;PropertyGroup&gt;     &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;     &lt;!-- ... --&gt;   &lt;\/PropertyGroup&gt;  \t&lt;!-- ... --&gt;    &lt;ItemGroup&gt;   &lt;!-- ... --&gt;     &lt;PackageReference Include=\"EFCore.NamingConventions\" Version=\"5.0.2\" \/&gt;     &lt;PackageReference Include=\"Microsoft.AspNetCore.OData\" Version=\"8.0.0-preview3\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore\" Version=\"5.0.2\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore.Tools\" Version=\"5.0.2\"&gt;       &lt;PrivateAssets&gt;all&lt;\/PrivateAssets&gt;       &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers; buildtransitive&lt;\/IncludeAssets&gt;     &lt;\/PackageReference&gt;     &lt;PackageReference Include=\"Npgsql.EntityFrameworkCore.PostgreSQL\" Version=\"5.0.2\" \/&gt;     &lt;!-- ... --&gt;   &lt;\/ItemGroup&gt; <\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0432 \u0442\u043e\u0442 \u0432\u0438\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u0410 \u0432\u043e\u0442 \u0432 Startup \u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a 8 \u0432\u0435\u0440\u0441\u0438\u0438 (\u043f\u0440\u0435\u0432\u044c\u044e) Microsoft.AspNetCore.OData \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 ConfigureServices:<\/p>\n<pre><code class=\"cs\">public class Startup {     public IConfiguration Configuration { get; }      public Startup(IConfiguration configuration)     {         Configuration = configuration;     }      public void ConfigureServices(IServiceCollection services)     {         services.AddDbContext&lt;MyDbContext&gt;(options =&gt; options             .UseNpgsql(Configuration.GetValue&lt;string&gt;(\"ConStrings:Mdm\"),                 assembly =&gt; assembly.MigrationsAssembly(typeof(MyDbContext).Assembly.FullName))             .UseSnakeCaseNamingConvention());         services.AddControllers();          \/\/ OData         services.AddOData(opt =&gt; opt             .AddModel(\"odata\", GetEdmModel())             .Select()             .Filter()             .OrderBy()             .Count()             .Expand()         );     }        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)     {         if (env.IsDevelopment())         {             app.UseDeveloperExceptionPage();         }          app.UseRouting();         app.UseAuthorization();         app.UseEndpoints(endpoints =&gt; { endpoints.MapControllers(); });     }      private IEdmModel GetEdmModel()     {         var odataBuilder = new ODataConventionModelBuilder();         odataBuilder.EntitySet&lt;UsingSystem&gt;(\"UsingSystems\");         odataBuilder.EntitySet&lt;UploadTemplate&gt;(\"UploadTemplates\");          return odataBuilder.GetEdmModel();     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0432 \u0431\u0430\u0437\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0430\u0441\u044c \u0442\u0440\u0435\u0442\u044c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 JSON \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <\/p>\n<p><code>GET http:\/\/localhost:61268\/odata\/UsingSystems(1)?$expand=UploadTemplates<\/code> <\/p>\n<p>\u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\">{     \"@odata.context\": \"http:\/\/myAPI.com\/odata\/$metadata#UsingSystems(UploadTemplates())\",     \"value\": [         {             \"Name\": \"\u0421\u0438\u0441\u0442\u0435\u043c\u04301\",             \"Description\": \"\u041f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430\",             \"Id\": 1,             \"UploadTemplates\": [                 {                     \"Id\": 123,                     \"Name\": \"\u0428\u0430\u0431\u043b\u043e\u043d1\",                     \"Description\": \"\u041f\u0440\u043e\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\",                     \"ProcessName\": \"\u041f\u0440\u043e\u0446\u0435\u0441\u04411\"                 }             ]         }     ] } <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Entity FrameworkCore \u0434\u043b\u044f .NET 5 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u043d\u0430\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u0432\u044f\u0437\u0435\u0439, \u043d\u043e \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c EDM \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 OData \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u043c .NET 5+ \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c, \u0447\u0435\u043c .NET Core 3.1.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/alfastrah\/blog\/568414\/\"> https:\/\/habr.com\/ru\/company\/alfastrah\/blog\/568414\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043e\u0431\u043e\u0440\u043e\u0442\u0430. \u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 LTS \u0432\u0435\u0440\u0441\u0438\u0438 .NET Core 3.1, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0431\u044d\u043a\u044d\u043d\u0434 \u0434\u043b\u044f SPA, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u044f\u0434 Worker Service\u2019\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u0421\u042d\u0414.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431\u0449\u0438\u0445 \u043c\u0430\u0441\u0442\u0435\u0440-\u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0411\u0414 PostgreSQL, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u043b\u0438 \u0441\u0432\u0435\u0436\u0438\u0439 \u043e\u043f\u044b\u0442 \u0438 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f (\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u2013 \u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438) \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0440\u0435\u0448\u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c Web API \u043d\u0430 .NET Core 3.1, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0411\u0414 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ORM, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u043b\u043e\u0436\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u0438 \u043e\u043f\u044b\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 EF Core.  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 API \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432 OData. <\/p>\n<p>\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 API OData \u043d\u0430 .NET Core, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u043d\u0438\u0445 \u0432\u0435\u0441\u044c\u043c\u0430 \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u0430 \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0430\u0432\u0442\u043e\u0440\u044b \u0443\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0432\u0430\u0436\u043d\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b, \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f API OData \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c EF Core. \u041e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0434\u0435\u043b\u0435\u043d\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 \u0441\u0432\u044f\u0437\u0438 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 ASP.NET Core 3.1    <\/h2>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0432 Visual Studio 2019 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 ASP.NET Core Web API. \u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414 Postgres \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b Microsoft.EntityFrameworkCore, Npgsql.EntityFrameworkCore.PostgreSQL, \u0430 \u0442\u0430\u043a\u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043b\u044f Postgres \u043d\u044d\u0439\u043c\u0438\u043d\u0433\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0411\u0414, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442 EFCore.NamingConventions. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 OData \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043a\u0435\u0442 Microsoft.AspNetCore.OData:<\/p>\n<pre><code class=\"xml\">  &lt;ItemGroup&gt;     &lt;PackageReference Include=\"EFCore.NamingConventions\" Version=\"1.1.1\" \/&gt;     &lt;PackageReference Include=\"Microsoft.AspNetCore.OData\" Version=\"7.5.6\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore\" Version=\"3.1.11\" \/&gt;     &lt;PackageReference Include=\"Microsoft.EntityFrameworkCore.Tools\" Version=\"3.1.11\"&gt;       &lt;PrivateAssets&gt;all&lt;\/PrivateAssets&gt;       &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers; buildtransitive&lt;\/IncludeAssets&gt;     &lt;\/PackageReference&gt;     &lt;PackageReference Include=\"Newtonsoft.Json\" Version=\"12.0.3\" \/&gt;     &lt;PackageReference Include=\"Npgsql.EntityFrameworkCore.PostgreSQL\" Version=\"3.1.11\" \/&gt;   &lt;\/ItemGroup&gt;<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c \u0441\u0432\u044f\u0437\u0438 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e EF Core 3.1 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0434\u0432\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430. \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043f\u043e\u0434 .NET Framework, \u043b\u0438\u0431\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 .NET 5.  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0421\u0438\u0441\u0442\u0435\u043c \u0438 \u0428\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432: \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 public class BaseDictionaryEntry {     [Column(Order = 1)]     [Key]     public long Id { get; set; }      public string Name { get; set; }      public string Description { get; set; } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c public class UsingSystem : BaseDictionaryEntry {     public List&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public UsingSystem()     {         UploadTemplates = new List&lt;UploadTemplate&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 public class UploadTemplate : BaseDictionaryEntry {     public string ProcessName { get; set; }      public List&lt;UsingSystem&gt; UsingSystems { get; set; }      public UploadTemplate()     {         UsingSystems = new List&lt;UsingSystem&gt;();     } }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/ \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 public class MyDbContext : DbContext {     public virtual DbSet&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public virtual DbSet&lt;UsingSystem&gt; UsingSystems { get; set; }      public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)         : base(options)     {     }      public MyDbContext()     {     } }<\/code><\/pre>\n<p>Startup.cs \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/ Startup public class Startup {     public IConfiguration Configuration { get; }          public Startup(IConfiguration configuration)     {         Configuration = configuration;     }          public void ConfigureServices(IServiceCollection services)     {         \/\/ \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414         services.AddDbContext&lt;MyDbContext&gt;(options =&gt; options             .UseNpgsql(Configuration.GetValue&lt;string&gt;(\"ConString\"),                 assembly =&gt; assembly.MigrationsAssembly(typeof(MyDbContext).Assembly.FullName))             .UseSnakeCaseNamingConvention());          services.AddControllers();          \/\/ \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c OData         services.AddOData();     }      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)     {         if (env.IsDevelopment())         {             app.UseDeveloperExceptionPage();         }          app.UseRouting();         app.UseAuthorization();         app.UseEndpoints(endpoints =&gt;         {             endpoints.MapControllers();             endpoints.Select().Filter().OrderBy().Count().MaxTop(10).Expand();             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u0438 OData             endpoints.MapODataRoute(\"odata\", \"odata\", GetEdmModel());         });     }      \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 OData     private IEdmModel GetEdmModel()     {         var odataBuilder = new ODataConventionModelBuilder();         odataBuilder.EntitySet&lt;UsingSystem&gt;(\"UsingSystems\");         odataBuilder.EntitySet&lt;UploadTemplate&gt;(\"UploadTemplates\");          return odataBuilder.GetEdmModel();     } }<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<pre><code class=\"cs\">\/\/ \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 public class UsingSystemsController : BaseDictionaryController {     public UsingSystemsController(DbContext dbContext) : base(dbContext)     {     }      [EnableQuery]     public IActionResult Get()     {         return Ok(_dbContext.UsingSystems             .Include(x =&gt; x.UploadTemplates));     }      [EnableQuery]     public IActionResult Get(long key)     {         return Ok(_dbContext.UsingSystems             .Where(x =&gt; x.Id == key)             .Include(x =&gt; x.UploadTemplates));     } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:  <\/p>\n<blockquote>\n<p>System.InvalidOperationException: Unable to determine the relationship represented by navigation property &#8216;UsingSystem.UploadTemplates&#8217; of type &#8216;List&#8217;. Either manually configure the relationship, or ignore this property using the &#8216;[NotMapped]&#8217; attribute or by using &#8216;EntityTypeBuilder.Ignore&#8217; in &#8216;OnModelCreating&#8217;.<\/p>\n<\/blockquote>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e Entity Framework Core \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0435\u043c\u0443 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e \u0441\u0432\u044f\u0437\u044c\u044e \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb \u0434\u043b\u044f .NET Core 3.1 <\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 UsingSystem \u0438 UploadTemplates, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:     <\/p>\n<pre><code class=\"cs\">\/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 public class BaseDictionaryEntry {     [Column(Order = 1)]     [Key]     public long Id { get; set; }      public string Name { get; set; }      public string Description { get; set; } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c public class UsingSystem : BaseDictionaryEntry {     public List&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public UsingSystem()     {         UploadTemplateUsingSystems = new List&lt;UploadTemplateUsingSystem&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 public class UploadTemplate : BaseDictionaryEntry {     public string ProcessName { get; set; }      public List&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public UploadTemplate()     {         UploadTemplateUsingSystems = new List&lt;UploadTemplateUsingSystem&gt;();     } }  \/\/ \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0438\u0442\u0435\u043c \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 public class UploadTemplateUsingSystem {     public long UploadTemplateId { get; set; }      public UploadTemplate UploadTemplate { get; set; }      public long UsingSystemId { get; set; }      public UsingSystem UsingSystem { get; set; } }  \/\/ \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 public class MyDbContext : DbContext {     public virtual DbSet&lt;UploadTemplate&gt; UploadTemplates { get; set; }      public virtual DbSet&lt;UsingSystem&gt; UsingSystems { get; set; }      public virtual DbSet&lt;UploadTemplateUsingSystem&gt; UploadTemplateUsingSystems { get; set; }      public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)         : base(options)     {     }      public MyDbContext()     {     }      protected override void OnModelCreating(ModelBuilder modelBuilder)     {         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasKey(x =&gt; new {x.UploadTemplateId, x.UsingSystemId});         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasOne(x =&gt; x.UploadTemplate)             .WithMany(x =&gt; x.UploadTemplateUsingSystems)             .HasForeignKey(x =&gt; x.UploadTemplateId);         modelBuilder.Entity&lt;UploadTemplateUsingSystem&gt;()             .HasOne(x =&gt; x.UsingSystem)             .WithMany(x =&gt; x.UploadTemplateUsingSystems)             .HasForeignKey(x =&gt; x.UsingSystemId);     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u0430\u043a \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0440\u0438\u0447\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e UploadTemplateUsingSystem \u0438\u043c\u0435\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u043a\u043b\u044e\u0447, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0438 Edm \u043c\u043e\u0434\u0435\u043b\u0438. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 $expand \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 API. \u041c\u0435\u0442\u043e\u0434 GetEdmModel \u0432 Startup \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">    private IEdmModel GetEdmModel()     {         var odataBuilder = new ODataConventionModelBuilder();         odataBuilder.EntitySet&lt;UsingSystem&gt;(\"UsingSystems\");         odataBuilder.EntitySet&lt;UploadTemplate&gt;(\"UploadTemplates\");<\/code><\/pre>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326674","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326674"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326674\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}