{"id":6761,"date":"2024-11-14T09:47:18","date_gmt":"2024-11-14T01:47:18","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6761\/"},"modified":"2024-11-14T09:47:18","modified_gmt":"2024-11-14T01:47:18","slug":"%e5%a6%82%e4%bd%95%e9%81%bf%e5%85%8d%e7%bc%96%e5%86%99%e6%a8%a1%e5%9e%8b%e7%b1%bb%ef%bc%9acodefirst-%e5%92%8c-dbfirst-%e7%9a%84%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6761\/","title":{"rendered":"\u5982\u4f55\u907f\u514d\u7f16\u5199\u6a21\u578b\u7c7b\uff1aCodeFirst \u548c DbFirst \u7684\u5e94\u7528"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/172990460498240.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u907f\u514d\u7f16\u5199\u6a21\u578b\u7c7b\uff1aCodeFirst \u548c DbFirst \u7684\u5e94\u7528\u63d2\u56fe\" alt=\"\u5982\u4f55\u907f\u514d\u7f16\u5199\u6a21\u578b\u7c7b\uff1aCodeFirst \u548c DbFirst \u7684\u5e94\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>\u514d\u5199\u6a21\u578b\u7c7b\u7684 ORM \u89e3\u51b3\u4e4b\u9053<\/strong><\/p>\n<p>\u5728\u7f16\u5199\u65b0\u8868\u67e5\u8be2\u65f6\uff0c\u5e38\u5e38\u9700\u8981\u6784\u5efa\u6a21\u578b\u7c7b\u5e76\u6620\u5c04\u5b57\u6bb5\u3002\u6709\u6ca1\u6709\u529e\u6cd5\u7ed5\u5f00\u6b64\u6b65\u9aa4\uff0c\u76f4\u63a5\u751f\u6210\u6a21\u578b\u7c7b\u6216\u5b57\u6bb5\u6620\u5c04\u5462\uff1f<\/p>\n<p>\u662f\u7684\uff0c\u6709\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u4f60\u514d\u4e8e\u7f16\u5199\u6a21\u578b\u7c7b\uff1a<\/p>\n<p><strong>CodeFirst vs. DbFirst<\/strong><\/p>\n<p>\u8fd9\u91cc\u6d89\u53ca\u5230\u4e00\u4e2a\u6982\u5ff5\uff0c\u5373 CodeFirst\uff08\u5148\u6709\u6a21\u578b\u4ee3\u7801\uff09\u4e0e DbFirst\uff08\u5148\u6709\u8868\u7ed3\u6784\uff09\u3002CodeFirst \u610f\u5473\u7740\u5148\u7f16\u5199\u6a21\u578b\u4ee3\u7801\uff0c\u7136\u540e\u57fa\u4e8e\u4ee3\u7801\u521b\u5efa\u8868\u7ed3\u6784\uff1bDbFirst \u5219\u76f8\u53cd\uff0c\u5148\u521b\u5efa\u8868\u7ed3\u6784\uff0c\u7136\u540e\u751f\u6210\u6a21\u578b\u4ee3\u7801\u3002<\/p>\n<p><strong>\u4f7f\u7528\u6846\u67b6\u7684\u652f\u6301<\/strong><\/p>\n<p>Django \u540c\u65f6\u652f\u6301 CodeFirst \u548c DbFirst\u3002\u4f60\u53ef\u4ee5\u53ea\u7f16\u5199\u4e00\u65b9\uff0c\u7136\u540e\u4f7f\u7528\u5b83\u63d0\u4f9b\u7684\u5de5\u5177\u5c06\u53e6\u4e00\u65b9\u8f6c\u6362\u51fa\u6765\u3002<\/p>\n<p><strong>\u66ff\u4ee3\u65b9\u6848<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528 Flask \u7b49\u6846\u67b6\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u641c\u7d22\u201c\u6846\u67b6\u540d\u79f0 + DbFirst\/CodeFirst\u201d\u3002\u8fd9\u53ef\u80fd\u4f1a\u4e3a\u4f60\u63d0\u4f9b\u4e00\u4e9b\u66ff\u4ee3\u65b9\u6848\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u907f\u514d\u7f16\u5199\u6a21\u578b\u7c7b\uff1aCodeFirst \u548c DbFirst \u7684\u5e94\u7528\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u514d\u5199\u6a21\u578b\u7c7b\u7684 ORM \u89e3\u51b3\u4e4b\u9053 \u5728\u7f16\u5199\u65b0\u8868\u67e5\u8be2\u65f6\uff0c\u5e38\u5e38\u9700\u8981\u6784\u5efa\u6a21\u578b\u7c7b\u5e76\u6620\u5c04\u5b57\u6bb5\u3002\u6709\u6ca1\u6709\u529e\u6cd5\u7ed5\u5f00\u6b64\u6b65\u9aa4\uff0c\u76f4\u63a5\u751f\u6210\u6a21\u578b\u7c7b\u6216\u5b57\u6bb5\u6620\u5c04\u5462\uff1f \u662f\u7684\uff0c\u6709\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u4f60\u514d\u4e8e\u7f16\u5199\u6a21\u578b\u7c7b\uff1a CodeFirst vs. DbFirst \u8fd9\u91cc\u6d89\u53ca\u5230\u4e00\u4e2a\u6982\u5ff5\uff0c\u5373 CodeFirst\uff08\u5148\u6709\u6a21\u578b\u4ee3\u7801\uff09\u4e0e DbFirst\uff08\u5148\u6709\u8868\u7ed3\u6784\uff09\u3002CodeFirst \u610f\u5473\u7740\u5148\u7f16\u5199\u6a21\u578b\u4ee3\u7801\uff0c\u7136\u540e\u57fa\u4e8e\u4ee3\u7801\u521b\u5efa\u8868\u7ed3\u6784\uff1bDbFirst \u5219\u76f8\u53cd\uff0c\u5148\u521b\u5efa\u8868\u7ed3\u6784\uff0c\u7136\u540e\u751f\u6210\u6a21\u578b\u4ee3\u7801\u3002 \u4f7f\u7528\u6846\u67b6\u7684\u652f\u6301 Django \u540c\u65f6\u652f\u6301 CodeFirst \u548c DbFirst\u3002\u4f60\u53ef\u4ee5\u53ea\u7f16\u5199\u4e00\u65b9\uff0c\u7136\u540e\u4f7f\u7528\u5b83\u63d0\u4f9b\u7684\u5de5\u5177\u5c06\u53e6\u4e00\u65b9\u8f6c\u6362\u51fa\u6765\u3002 \u66ff\u4ee3\u65b9\u6848 \u5982\u679c\u4f60\u4f7f\u7528 Flask \u7b49\u6846\u67b6\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u641c\u7d22\u201c\u6846\u67b6\u540d\u79f0 + DbFirst\/CodeFirst\u201d\u3002\u8fd9\u53ef\u80fd\u4f1a\u4e3a\u4f60\u63d0\u4f9b\u4e00\u4e9b\u66ff\u4ee3\u65b9\u6848\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u907f\u514d\u7f16\u5199\u6a21\u578b\u7c7b\uff1aCodeFirst \u548c DbFirst \u7684\u5e94\u7528\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6761","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6761"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6761\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}