{"id":337895,"date":"2022-09-04T09:00:05","date_gmt":"2022-09-04T09:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337895"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337895","title":{"rendered":"<span>\u041f\u043e\u0432\u0430\u0440\u0435\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0411\u0414 \u0438\u043b\u0438 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u044e<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0434\u043d\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0411\u0414 &#8212; \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0421\u0423\u0411\u0414 \u0438\u043b\u0438 \u0441\u0445\u0435\u043c\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0447\u0442\u043e-\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0412\u044b \u043d\u0435 \u0444\u0430\u043d\u0430\u0442 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0445 SQL \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 PostgreSQL \u0438 EF Core \u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u044e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435\u0442 \u043d\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 .Net \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u0441\u0442\u043e\u0438\u0442 \u0434\u0440\u0443\u0433\u0430\u044f \u0421\u0423\u0411\u0414.<\/h3>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0431\u0435\u0437 C# \u043a\u043e\u0434\u0430.<\/h3>\n<p>\u042d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443, \u043b\u0438\u0431\u043e \u0432\u044b \u0432\u0441\u0451 \u0435\u0449\u0451 \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0438\u0441\u0430\u0442\u044c SQL.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1: \u0411\u044d\u043a\u0430\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 \u0441 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u044d\u043a\u0430\u043f\u0430 \u043d\u0430 \u0411\u0414 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435<\/h3>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u043e\u043c \u0447\u0442\u043e \u0432 \u0431\u044d\u043a\u0430\u043f \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0447\u0435\u0433\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430.<br \/> \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u0431\u043b\u0438\u0446 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p><code>pg_dump.exe --file \"D:\\\\Backups\\\\books\" --host \"localhost\" --port \"5432\" --username \"postgres\" --no-password --verbose --format=c --blobs --section=data --table \"dbo.books\" --table \"dbo.flowers\" \"SourceDatabase\"<\/code><\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u044d\u043a\u0430\u043f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>pg_restore<\/code>, \u043b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 UI, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0430\u043a\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u043a pgAdmin.<\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u0434. \u041d\u043e \u043a\u0430\u043a \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u043e\u043d \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0445\u0432\u0430\u0442\u043a\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>      \u2013\u00a0\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>pg_dump<\/code>, \u043d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0435\u0441\u043b\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f ID.<\/p>\n<p>      \u2013\u00a0\u041a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 CSV. \u0415\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 &#8212; \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2: SQL \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u043c \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0447\u0435\u0440\u0435\u0437 CSV<\/h3>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442 CSV \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 50 \u043b\u0435\u0442(\u0441 1972). \u0418 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0435 \u0448\u0430\u043d\u0441\u044b \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430 \u041c\u0430\u0440\u0441\u0435. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0448\u0435\u0439 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0412 PostgreSQL \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432 CSV \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 COPY.<\/p>\n<p><code>COPY \"dbo.books\" TO '\/usr1\/proj\/bray\/sql\/all_the_books.csv'\u00a0 WITH DELIMITER ',' CSV HEADER;<br \/> COPY (SELECT * FROM \"dbo.books\") to '\/usr1\/proj\/bray\/sql\/all_the_books.csv'\u00a0 WITH DELIMITER ',' CSV HEADER;<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c SQL. \u0421\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 3: SQL \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 dblink<\/h3>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 dblink \u0432 PostgreSQL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u0411\u0414. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0431\u0434 \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u0412 \u0441\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 &#8212; \u044d\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u043e\u0439 INSERT SELECT, \u043d\u043e SELECT \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0411\u0414.<\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0433\u0438\u0431\u043a\u043e, \u043d\u043e \u0440\u0430\u0441\u0442\u0451\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0430 \u0441 \u043d\u0435\u0439 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u043d\u043e\u0433\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0411\u0414 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0431\u043e\u0438\u043b\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0411\u0414 \u0431\u043e\u043b\u0435\u0435 15 \u0413\u0411 \u0437\u0430 \u0440\u0430\u0437. \u0427\u0442\u043e \u0431 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 dblink \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c C# \u043a\u043e\u0434\u0430<\/h3>\n<p>\u042d\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u0438 \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u0438 \u0434\u043b\u044f \u0411\u0414 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0432\u044b\u0445 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 &#171;\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0411\u0414&#187;<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1. dblink \u043d\u043e \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434<\/h3>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 SQL \u043b\u0438\u0431\u043e C# \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 SQL. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p><code>_destination.Database.ExecuteSqlRaw($\"CREATE EXTENSION dblink\");<\/code><\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e DbContext \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043b\u0438\u0431\u043e \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043f\u043e \u043f\u043e\u043b\u044e yearofpublication, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044e.<\/h4>\n<p>\u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0441\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0440\u0430\u0441\u0441\u0447\u0451\u0442\u0435 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430 \u043f\u043e \u0441\u0445\u0435\u043c\u0435.<\/p>\n<p>\u00a0<code>public string GetEntityMigrationString(Type type, DbContext context, int? year = null)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var tableName = GetTableName(context, type);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var propertiesDictionary = GetTypeProperties(context, type);<br \/> \u00a0\u00a0\u00a0\u00a0 var propertiesString = string.Join(\", \", propertiesDictionary.Select(p => p.Key));<br \/> \u00a0\u00a0\u00a0\u00a0 var propertiesWithTypesString = string.Join(\", \", propertiesDictionary.Select(p => p.Value));<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var sqlString =<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\"INSERT INTO {tableName}({propertiesString}) SELECT {propertiesString} FROM dblink('{_sourceString}', 'SELECT {propertiesString} from {tableName}\";<br \/> \u00a0\u00a0\u00a0\u00a0 if (year != null)<br \/> \u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sqlString +=<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\" where yearofpublication >= {year} and yearofpublication &lt;= {year} ORDER BY yearofpublication ASC\";<br \/> \u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 sqlString +=<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\"') AS x({propertiesWithTypesString})\";<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 return sqlString;<br \/> \u00a0}<\/p>\n<p> \u00a0private static string GetTableName(DbContext context, Type type)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var entityType = context.Model.FindEntityType(type);<br \/> \u00a0\u00a0\u00a0\u00a0 var tableSchema = entityType.GetSchema();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var tableName = tableSchema == null<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ? entityType.GetTableName()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : tableSchema + '.' + entityType.GetTableName();<br \/> \u00a0\u00a0\u00a0\u00a0 return tableName;<br \/> \u00a0}<\/p>\n<p> \u00a0private static Dictionary&lt;string, string> GetTypeProperties(DbContext context, Type type)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var entityType = context.Model.FindEntityType(type);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var propertiesDictionary = new Dictionary&lt;string, string>();<br \/> \u00a0\u00a0\u00a0\u00a0 foreach (var property in entityType.GetProperties())<br \/> \u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var propertyColumnName = property.GetColumnName();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var propertyColumnNamePlusType = property.GetColumnName() + \" \" + property.GetColumnType();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 propertiesDictionary.Add(propertyColumnName, propertyColumnNamePlusType);<br \/> \u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 return propertiesDictionary;<br \/> \u00a0}<\/code><\/p>\n<p>\u042d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432 \u0411\u0414 \u0447\u0435\u0440\u0435\u0437 ExecuteSqlRaw.<\/p>\n<p>\u00a0<code>public void MigrateTable(Type type, DbContext referenceContext)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var tableName = GetTableName(referenceContext, type);<br \/> \u00a0\u00a0\u00a0\u00a0 var dataMigrationString = GetEntityMigrationString(type, referenceContext);<br \/> \u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"Started importing {tableName} at {DateTime.Now:h:mm:ss tt}\");<br \/> \u00a0\u00a0\u00a0\u00a0 _destination.Database.ExecuteSqlRaw(dataMigrationString);<br \/> \u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"Imported {tableName} at {DateTime.Now:h:mm:ss tt}\");<br \/> \u00a0}<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u042d\u0442\u043e \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0443\u0436\u0435\u043d SQL. \u00a0<br \/>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. C# \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u0437\u0430\u0441\u044b\u043f\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0430\u0445\u0430\u0440\u043e\u043c \u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0441\u0432\u0435\u0440\u0445\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u042d\u0442\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u044f\u0434 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SQL.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0411\u0414 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0431\u043e\u0438\u043b\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0411\u0414 \u0431\u043e\u043b\u0435\u0435 15 \u0433\u0431 \u0437\u0430 \u0440\u0430\u0437. \u0427\u0442\u043e \u0431 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 dblink \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0444\u0435\u0440\u0435\u043d\u0441\u044b: <a href=\"https:\/\/www.postgresql.org\/docs\/current\/contrib-dblink-function.html\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f PostgreSQL \u043f\u043e dblink<\/a><\/p>\n<h4>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2. \u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 EF Core<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 EF Core.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Books \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 Id.<\/p>\n<p>\u00a0\u00a0\u00a0 <code>public static class BooksMigration<br \/> \u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public static async Task&lt;Dictionary&lt;int, Guid>> MigrateBooks(ContextsOptions contextsOptions)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var changedIds = new Dictionary&lt;int, Guid>();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await using (var destinationContext = new DestinationContext(contextsOptions.DestinationDatabaseContextOptions))<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await using (var legacyContext = new SourceContext(contextsOptions.SourceDatabaseContextOptions))<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 legacyContext.Books.AsNoTracking().ToList().ForEach(sourceBook =><br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (legacyContext == null || destinationContext == null)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw new ArgumentNullException();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationBook = InsertBookToDestination(destinationContext, sourceBook);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"{sourceBook.Globalname} transferred, new id: {destinationBook.Id}(was {sourceBook.Id})\");<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 changedIds.Add(sourceBook.Id, destinationBook.Id);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 });<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await destinationContext.SaveChangesAsync();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return changedIds;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 private static Book InsertBookToDestination(DestinationContext destinationContext, Book sourceBook)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return destinationContext.Books.Add(new Book<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name = sourceBook.Name,<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AuthorId = sourceBook.AuthorId,<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Code = sourceBook.Code<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }).Entity;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/code><\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u043a\u043e\u0434\u0435 ContextsOptions<\/p>\n<p>\u00a0\u00a0\u00a0 <code>public class ContextsOptions<br \/> \u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public DbContextOptions&lt;SourceContext> SourceDatabaseContextOptions { get; }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public DbContextOptions&lt;DestinationContext> DestinationDatabaseContextOptions { get; }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public ContextsOptions(DbContextOptions&lt;SourceContext> sourceDatabaseContextOptions, DbContextOptions&lt;DestinationContext> destinationDatabaseContextOptions)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0SourceDatabaseContextOptions = sourceDatabaseContextOptions;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DestinationDatabaseContextOptions = destinationDatabaseContextOptions;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 <br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public static ContextsOptions GetContextsOptions()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 const string configPath = \"appsettings.json\";<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var config = new ConfigurationBuilder()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .AddJsonFile(configPath)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Build();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var sourceDatabase = config.GetConnectionString(\"SourceDatabase\");<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationDatabase = config.GetConnectionString(\"DestinationDatabase\");<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var sourceDatabaseContextOptions = new DbContextOptionsBuilder&lt;SourceContext>()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UseNpgsql(sourceDatabase)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Options;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationDatabaseContextOptions = new DbContextOptionsBuilder&lt;DestinationContext>()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UseNpgsql(destinationDatabase)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Options;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return new ContextsOptions(sourceDatabaseContextOptions, destinationDatabaseContextOptions);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 }<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u043e. \u0421\u043c\u044f\u0433\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0431\u043b\u043e\u043a\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. <\/p>\n<\/li>\n<li>\n<p>by design\u2122 EF Core \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445, \u0447\u0442\u043e \u0431 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0411\u0414. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>\u0420\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c AsNoTracking() \u0438 \u0435\u0433\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 AsNoTrackingWithIdentityResolution(), \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0441 EF Core 5+.<\/p>\n<\/li>\n<li>\n<p>EF Core \u043d\u0435 \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0411\u0414 \u0437\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0435\u043b\u0430\u0442\u044c bulk insert. Bulk insert \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 EF Core \u0438 \u0434\u0430\u0451\u0442 \u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>&#8212; \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Bulk Insert \u0438\u0437 \u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e <a href=\"https:\/\/entityframework-extensions.net\/\" rel=\"noopener noreferrer nofollow\">Entity Framework Extensions<\/a> (\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434)<br \/>&#8212; <a href=\"https:\/\/github.com\/npgsql\/npgsql\/issues\/2779#issuecomment-573439342\" rel=\"noopener noreferrer nofollow\">\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432<\/a> \u0434\u043b\u044f Npgsql \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PostgreSQL. \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041d\u0435\u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b<\/h3>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1: Insert + Select<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0411\u0414, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 insert + select \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p><code>INSERT INTO TDestination (Id, Name)<br \/> SELECT Id, Name FROM TOrigin<br \/> WHERE Name ='John';<\/code><\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2: \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 EF Core<\/h3>\n<p>EF Core \u043d\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u0440\u0430\u0437 by design\u2122. \u0422\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435 \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d. \u041d\u043e \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e\u0439\u0434\u0451\u0442.<\/p>\n<p><code>public void StraightforwardMigration(SourceContext sourceContext, DestinationContext destination)<br \/> {<br \/> \u00a0\u00a0\u00a0 destination.AddRange(sourceContext.Files);<br \/> }<\/code><\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0411\u0414<\/h3>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0443\u043d\u043a\u0442 \u043d\u0443\u0436\u0435\u043d \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u0434\u043b\u044f EF Core. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 Scaffold. \u042d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f EF Core \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0411\u0414.<br \/>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0434\u043b\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e solution: <\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0432\u0430\u0448\u0435\u043c Solution<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430 \u043d\u0435\u0433\u043e \u0432 \u0432\u0430\u0448\u0435\u043c Startup \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442 Microsoft.EntityFrameworkCore.Design <\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 Scaffold \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<\/li>\n<\/ol>\n<p><code>dotnet ef dbcontext scaffold \"Host=localhost;Port=5432;Database=SourceDatabase;Username=Superuser;Password=Superuser\" Npgsql.EntityFrameworkCore.PostgreSQL -Context SourceScaffoldContext -OutputDir SourceScaffold<\/code><\/p>\n<p>Visual studio<\/p>\n<p><code>Scaffold-DbContext \"Host=localhost;Port=5432;Database=SourceDatabase;Username=Superuser;Password=Superuser\" Npgsql.EntityFrameworkCore.PostgreSQL -Context SourceScaffoldContext -OutputDir SourceScaffold<\/code><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f PostgreSQL, \u043d\u043e \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SqlServer, Cosmos, MySql \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0411\u0414 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 EF Core \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440. <a href=\"https:\/\/docs.microsoft.com\/en-us\/ef\/core\/providers\/?tabs=dotnet-core-cli\" rel=\"noopener noreferrer nofollow\">\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432<\/a><\/p>\n<h4>\u041d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f<\/h4>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Scaffold \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e, \u0447\u0438\u0441\u0442\u043e, \u043d\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442. \u0415\u0441\u043b\u0438 \u0432\u044b \u043c\u0438\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u043d\u0430 EF Core &#8212; \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0412 PostgreSQL \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043a\u043b\u044e\u0447\u0430\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>ALTER TABLE {table} DISABLE TRIGGER ALL<\/code> \u043d\u043e, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<h4>\u0412\u044b\u0432\u043e\u0434\u044b<\/h4>\n<p>\u041a\u0430\u043a \u044f \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 &#8212; \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0411\u0414 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u043b\u0451\u0433\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0414\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0441\u043e\u0447\u0435\u0442\u0430\u043b \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u0447\u0442\u043e \u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u043e\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e.<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u0442\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u044f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e EF Core, \u0432 \u0441\u0438\u043b\u0443 \u0442\u043e\u0433\u043e \u0432 \u043a\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/686262\/\"> https:\/\/habr.com\/ru\/post\/686262\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0434\u043d\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0411\u0414 &#8212; \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0421\u0423\u0411\u0414 \u0438\u043b\u0438 \u0441\u0445\u0435\u043c\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0447\u0442\u043e-\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0412\u044b \u043d\u0435 \u0444\u0430\u043d\u0430\u0442 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0445 SQL \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 PostgreSQL \u0438 EF Core \u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u044e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435\u0442 \u043d\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 .Net \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u0441\u0442\u043e\u0438\u0442 \u0434\u0440\u0443\u0433\u0430\u044f \u0421\u0423\u0411\u0414.<\/h3>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0431\u0435\u0437 C# \u043a\u043e\u0434\u0430.<\/h3>\n<p>\u042d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443, \u043b\u0438\u0431\u043e \u0432\u044b \u0432\u0441\u0451 \u0435\u0449\u0451 \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0438\u0441\u0430\u0442\u044c SQL.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1: \u0411\u044d\u043a\u0430\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 \u0441 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u044d\u043a\u0430\u043f\u0430 \u043d\u0430 \u0411\u0414 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435<\/h3>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u043e\u043c \u0447\u0442\u043e \u0432 \u0431\u044d\u043a\u0430\u043f \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0447\u0435\u0433\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430.<br \/> \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u0431\u043b\u0438\u0446 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p><code>pg_dump.exe --file \"D:\\\\Backups\\\\books\" --host \"localhost\" --port \"5432\" --username \"postgres\" --no-password --verbose --format=c --blobs --section=data --table \"dbo.books\" --table \"dbo.flowers\" \"SourceDatabase\"<\/code><\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u044d\u043a\u0430\u043f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>pg_restore<\/code>, \u043b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 UI, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0430\u043a\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u043a pgAdmin.<\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u0434. \u041d\u043e \u043a\u0430\u043a \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u043e\u043d \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0445\u0432\u0430\u0442\u043a\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>      \u2013\u00a0\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>pg_dump<\/code>, \u043d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0435\u0441\u043b\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f ID.<\/p>\n<p>      \u2013\u00a0\u041a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 CSV. \u0415\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 &#8212; \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2: SQL \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u043c \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c \u0447\u0435\u0440\u0435\u0437 CSV<\/h3>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442 CSV \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 50 \u043b\u0435\u0442(\u0441 1972). \u0418 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0435 \u0448\u0430\u043d\u0441\u044b \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430 \u041c\u0430\u0440\u0441\u0435. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0448\u0435\u0439 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0412 PostgreSQL \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432 CSV \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 COPY.<\/p>\n<p><code>COPY \"dbo.books\" TO '\/usr1\/proj\/bray\/sql\/all_the_books.csv'\u00a0 WITH DELIMITER ',' CSV HEADER;<br \/> COPY (SELECT * FROM \"dbo.books\") to '\/usr1\/proj\/bray\/sql\/all_the_books.csv'\u00a0 WITH DELIMITER ',' CSV HEADER;<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c SQL. \u0421\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 3: SQL \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 dblink<\/h3>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 dblink \u0432 PostgreSQL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u0411\u0414. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0431\u0434 \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u0412 \u0441\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 &#8212; \u044d\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u043e\u0439 INSERT SELECT, \u043d\u043e SELECT \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0411\u0414.<\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0433\u0438\u0431\u043a\u043e, \u043d\u043e \u0440\u0430\u0441\u0442\u0451\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0430 \u0441 \u043d\u0435\u0439 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u043d\u043e\u0433\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0411\u0414 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0431\u043e\u0438\u043b\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0411\u0414 \u0431\u043e\u043b\u0435\u0435 15 \u0413\u0411 \u0437\u0430 \u0440\u0430\u0437. \u0427\u0442\u043e \u0431 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 dblink \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c C# \u043a\u043e\u0434\u0430<\/h3>\n<p>\u042d\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u0438 \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u0438 \u0434\u043b\u044f \u0411\u0414 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0432\u044b\u0445 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 &#171;\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0411\u0414&#187;<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1. dblink \u043d\u043e \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434<\/h3>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 SQL \u043b\u0438\u0431\u043e C# \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 SQL. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p><code>_destination.Database.ExecuteSqlRaw($\"CREATE EXTENSION dblink\");<\/code><\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e DbContext \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043b\u0438\u0431\u043e \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043f\u043e \u043f\u043e\u043b\u044e yearofpublication, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044e.<\/h4>\n<p>\u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0441\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0440\u0430\u0441\u0441\u0447\u0451\u0442\u0435 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0411\u0414 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0430 \u043f\u043e \u0441\u0445\u0435\u043c\u0435.<\/p>\n<p>\u00a0<code>public string GetEntityMigrationString(Type type, DbContext context, int? year = null)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var tableName = GetTableName(context, type);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var propertiesDictionary = GetTypeProperties(context, type);<br \/> \u00a0\u00a0\u00a0\u00a0 var propertiesString = string.Join(\", \", propertiesDictionary.Select(p => p.Key));<br \/> \u00a0\u00a0\u00a0\u00a0 var propertiesWithTypesString = string.Join(\", \", propertiesDictionary.Select(p => p.Value));<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var sqlString =<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\"INSERT INTO {tableName}({propertiesString}) SELECT {propertiesString} FROM dblink('{_sourceString}', 'SELECT {propertiesString} from {tableName}\";<br \/> \u00a0\u00a0\u00a0\u00a0 if (year != null)<br \/> \u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sqlString +=<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\" where yearofpublication >= {year} and yearofpublication &lt;= {year} ORDER BY yearofpublication ASC\";<br \/> \u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 sqlString +=<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $\"') AS x({propertiesWithTypesString})\";<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 return sqlString;<br \/> \u00a0}<\/p>\n<p> \u00a0private static string GetTableName(DbContext context, Type type)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var entityType = context.Model.FindEntityType(type);<br \/> \u00a0\u00a0\u00a0\u00a0 var tableSchema = entityType.GetSchema();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var tableName = tableSchema == null<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ? entityType.GetTableName()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : tableSchema + '.' + entityType.GetTableName();<br \/> \u00a0\u00a0\u00a0\u00a0 return tableName;<br \/> \u00a0}<\/p>\n<p> \u00a0private static Dictionary&lt;string, string> GetTypeProperties(DbContext context, Type type)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var entityType = context.Model.FindEntityType(type);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 var propertiesDictionary = new Dictionary&lt;string, string>();<br \/> \u00a0\u00a0\u00a0\u00a0 foreach (var property in entityType.GetProperties())<br \/> \u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var propertyColumnName = property.GetColumnName();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var propertyColumnNamePlusType = property.GetColumnName() + \" \" + property.GetColumnType();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 propertiesDictionary.Add(propertyColumnName, propertyColumnNamePlusType);<br \/> \u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0 return propertiesDictionary;<br \/> \u00a0}<\/code><\/p>\n<p>\u042d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432 \u0411\u0414 \u0447\u0435\u0440\u0435\u0437 ExecuteSqlRaw.<\/p>\n<p>\u00a0<code>public void MigrateTable(Type type, DbContext referenceContext)<br \/> \u00a0{<br \/> \u00a0\u00a0\u00a0\u00a0 var tableName = GetTableName(referenceContext, type);<br \/> \u00a0\u00a0\u00a0\u00a0 var dataMigrationString = GetEntityMigrationString(type, referenceContext);<br \/> \u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"Started importing {tableName} at {DateTime.Now:h:mm:ss tt}\");<br \/> \u00a0\u00a0\u00a0\u00a0 _destination.Database.ExecuteSqlRaw(dataMigrationString);<br \/> \u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"Imported {tableName} at {DateTime.Now:h:mm:ss tt}\");<br \/> \u00a0}<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u042d\u0442\u043e \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0443\u0436\u0435\u043d SQL. \u00a0<br \/>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0411\u0414 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. C# \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u0437\u0430\u0441\u044b\u043f\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0430\u0445\u0430\u0440\u043e\u043c \u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0441\u0432\u0435\u0440\u0445\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u042d\u0442\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u044f\u0434 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SQL.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0411\u0414 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0431\u043e\u0438\u043b\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0411\u0414 \u0431\u043e\u043b\u0435\u0435 15 \u0433\u0431 \u0437\u0430 \u0440\u0430\u0437. \u0427\u0442\u043e \u0431 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 dblink \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0444\u0435\u0440\u0435\u043d\u0441\u044b: <a href=\"https:\/\/www.postgresql.org\/docs\/current\/contrib-dblink-function.html\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f PostgreSQL \u043f\u043e dblink<\/a><\/p>\n<h4>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2. \u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 EF Core<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 EF Core.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Books \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 Id.<\/p>\n<p>\u00a0\u00a0\u00a0 <code>public static class BooksMigration<br \/> \u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public static async Task&lt;Dictionary&lt;int, Guid>> MigrateBooks(ContextsOptions contextsOptions)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var changedIds = new Dictionary&lt;int, Guid>();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await using (var destinationContext = new DestinationContext(contextsOptions.DestinationDatabaseContextOptions))<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await using (var legacyContext = new SourceContext(contextsOptions.SourceDatabaseContextOptions))<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 legacyContext.Books.AsNoTracking().ToList().ForEach(sourceBook =><br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (legacyContext == null || destinationContext == null)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0throw new ArgumentNullException();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationBook = InsertBookToDestination(destinationContext, sourceBook);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.WriteLine($\"{sourceBook.Globalname} transferred, new id: {destinationBook.Id}(was {sourceBook.Id})\");<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 changedIds.Add(sourceBook.Id, destinationBook.Id);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 });<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await destinationContext.SaveChangesAsync();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return changedIds;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 private static Book InsertBookToDestination(DestinationContext destinationContext, Book sourceBook)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return destinationContext.Books.Add(new Book<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name = sourceBook.Name,<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AuthorId = sourceBook.AuthorId,<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Code = sourceBook.Code<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }).Entity;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/code><\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u043a\u043e\u0434\u0435 ContextsOptions<\/p>\n<p>\u00a0\u00a0\u00a0 <code>public class ContextsOptions<br \/> \u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public DbContextOptions&lt;SourceContext> SourceDatabaseContextOptions { get; }<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public DbContextOptions&lt;DestinationContext> DestinationDatabaseContextOptions { get; }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public ContextsOptions(DbContextOptions&lt;SourceContext> sourceDatabaseContextOptions, DbContextOptions&lt;DestinationContext> destinationDatabaseContextOptions)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0SourceDatabaseContextOptions = sourceDatabaseContextOptions;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DestinationDatabaseContextOptions = destinationDatabaseContextOptions;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 <br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public static ContextsOptions GetContextsOptions()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 const string configPath = \"appsettings.json\";<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var config = new ConfigurationBuilder()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .AddJsonFile(configPath)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Build();<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var sourceDatabase = config.GetConnectionString(\"SourceDatabase\");<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationDatabase = config.GetConnectionString(\"DestinationDatabase\");<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var sourceDatabaseContextOptions = new DbContextOptionsBuilder&lt;SourceContext>()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UseNpgsql(sourceDatabase)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Options;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var destinationDatabaseContextOptions = new DbContextOptionsBuilder&lt;DestinationContext>()<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UseNpgsql(destinationDatabase)<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .Options;<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return new ContextsOptions(sourceDatabaseContextOptions, destinationDatabaseContextOptions);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 }<\/code><\/p>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u043e. \u0421\u043c\u044f\u0433\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0431\u043b\u043e\u043a\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. <\/p>\n<\/li>\n<li>\n<p>by design\u2122 EF Core \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445, \u0447\u0442\u043e \u0431 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0411\u0414. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>\u0420\u0435\u0448<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-337895","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337895","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=337895"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337895\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}