"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[6792],{2585:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>d,metadata:()=>o,toc:()=>a});var t=s(5893),r=s(1151),c=s(4996);const d={id:"net5-to-net6",title:"2.9 .NET5 \u5347\u7ea7 .NET6",sidebar_label:"2.9 .NET5 \u5347\u7ea7 .NET6",description:"\u4e86\u89e3\u5982\u4f55\u4ece .NET5 \u5347\u7ea7\u5230 .NET6"},i=void 0,o={id:"net5-to-net6",title:"2.9 .NET5 \u5347\u7ea7 .NET6",description:"\u4e86\u89e3\u5982\u4f55\u4ece .NET5 \u5347\u7ea7\u5230 .NET6",source:"@site/docs/net5-to-net6.mdx",sourceDirName:".",slug:"/net5-to-net6",permalink:"/docs/net5-to-net6",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/net5-to-net6.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1700811349,formattedLastUpdatedAt:"Nov 24, 2023",frontMatter:{id:"net5-to-net6",title:"2.9 .NET5 \u5347\u7ea7 .NET6",sidebar_label:"2.9 .NET5 \u5347\u7ea7 .NET6",description:"\u4e86\u89e3\u5982\u4f55\u4ece .NET5 \u5347\u7ea7\u5230 .NET6"},sidebar:"docs",previous:{title:"2.8 \u795e\u5947\u7684 Inject",permalink:"/docs/inject"},next:{title:"2.10 .NET6 \u5347\u7ea7 .NET7",permalink:"/docs/net6-to-net7"}},l={},a=[{value:"2.9.1 \u5347\u7ea7\u6ce8\u610f\u4e8b\u9879",id:"291-\u5347\u7ea7\u6ce8\u610f\u4e8b\u9879",level:2},{value:"2.9.1.1 \u5b89\u88c5 .NET6 SDK",id:"2911-\u5b89\u88c5-net6-sdk",level:3},{value:"2.9.1.2 \u7f16\u8f91 .csproj \u6587\u4ef6",id:"2912-\u7f16\u8f91-csproj-\u6587\u4ef6",level:3},{value:"2.9.1.3 \u5347\u7ea7 NuGet \u5305",id:"2913-\u5347\u7ea7-nuget-\u5305",level:3},{value:"2.9.1.4 \u5220\u9664 Startup.cs \u6587\u4ef6",id:"2914-\u5220\u9664-startupcs-\u6587\u4ef6",level:3},{value:"2.9.1.5 \u7f16\u8f91 Web \u542f\u52a8\u5c42 .csproj",id:"2915-\u7f16\u8f91-web-\u542f\u52a8\u5c42-csproj",level:3},{value:"2.9.1.6 \u66ff\u6362 Program.cs \u5185\u5bb9\u4e3a\uff1a",id:"2916-\u66ff\u6362-programcs-\u5185\u5bb9\u4e3a",level:3},{value:"2.9.1.7 \u91cd\u65b0\u7f16\u8bd1\u6574\u4e2a\u89e3\u51b3\u65b9\u6848",id:"2917-\u91cd\u65b0\u7f16\u8bd1\u6574\u4e2a\u89e3\u51b3\u65b9\u6848",level:3}];function p(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,r.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h2,{id:"291-\u5347\u7ea7\u6ce8\u610f\u4e8b\u9879",children:"2.9.1 \u5347\u7ea7\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsxs)(n.strong,{children:["\u76ee\u524d\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Furion"})," \u6240\u6709\u7248\u672c\uff080.x-3.x\uff09\u7684\u7528\u6237\u5747\u53ef\u4ee5\u5feb\u901f\u65e0\u7f1d\u5347\u7ea7\u81f3 ",(0,t.jsx)(n.code,{children:"Furion v4.x"})," \u7248\u672c\uff0c\u53ea\u9700\u8981\u505a\u5c11\u91cf\u66f4\u6539\u5373\u53ef\u3002"]})}),"\n",(0,t.jsxs)(n.h3,{id:"2911-\u5b89\u88c5-net6-sdk",children:["2.9.1.1 \u5b89\u88c5 ",(0,t.jsx)(n.code,{children:".NET6 SDK"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://dotnet.microsoft.com/download/dotnet/6.0",children:"https://dotnet.microsoft.com/download/dotnet/6.0"})}),"\n",(0,t.jsxs)(n.h3,{id:"2912-\u7f16\u8f91-csproj-\u6587\u4ef6",children:["2.9.1.2 \u7f16\u8f91 ",(0,t.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6"]}),"\n",(0,t.jsxs)(n.p,{children:["\u7f16\u8f91\u89e3\u51b3\u65b9\u6848\u6240\u6709\u9879\u76ee\u7684 ",(0,t.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6\uff0c\u5e76\u66ff\u6362 ",(0,t.jsx)(n.code,{children:"net5.0"})," \u4e3a ",(0,t.jsx)(n.code,{children:"net6.0"}),"\uff0c\u5982\uff1a"]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl1.png")}),"\n",(0,t.jsxs)(n.p,{children:["\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Ctrl + F"})," \u5168\u5c40\u66ff\u6362"]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl2.png")}),"\n",(0,t.jsxs)(n.h3,{id:"2913-\u5347\u7ea7-nuget-\u5305",children:["2.9.1.3 \u5347\u7ea7 ",(0,t.jsx)(n.code,{children:"NuGet"})," \u5305"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5c06 ",(0,t.jsx)(n.code,{children:"Furion"})," \u6240\u6709\u5305\u5347\u7ea7\u81f3 ",(0,t.jsx)(n.code,{children:"v4.9.1.7"})," \u7248\u672c\uff0c\u540c\u65f6 ",(0,t.jsx)(n.code,{children:"Microsoft"})," \u6240\u6709\u5305\u5347\u7ea7\u81f3 ",(0,t.jsx)(n.code,{children:"v6.0.25"})," \u7248\u672c\uff0c\u5982\uff1a"]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl3.png")}),"\n",(0,t.jsxs)(n.h3,{id:"2914-\u5220\u9664-startupcs-\u6587\u4ef6",children:["2.9.1.4 \u5220\u9664 ",(0,t.jsx)(n.code,{children:"Startup.cs"})," \u6587\u4ef6"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5220\u9664 ",(0,t.jsx)(n.code,{children:"Web \u542f\u52a8\u5c42"})," \u7684 ",(0,t.jsx)(n.code,{children:"Startup.cs"})," \u6587\u4ef6\uff0c\u5982\uff1a"]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl4.png")}),"\n",(0,t.jsxs)(n.h3,{id:"2915-\u7f16\u8f91-web-\u542f\u52a8\u5c42-csproj",children:["2.9.1.5 \u7f16\u8f91 ",(0,t.jsx)(n.code,{children:"Web"})," \u542f\u52a8\u5c42 ",(0,t.jsx)(n.code,{children:".csproj"})]}),"\n",(0,t.jsxs)(n.p,{children:["\u7f16\u8f91 ",(0,t.jsx)(n.code,{children:"Web"})," \u542f\u52a8\u5c42 ",(0,t.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0 ",(0,t.jsx)(n.code,{children:"enable"}),"\uff0c\u5982\uff1a"]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl5.png")}),"\n",(0,t.jsxs)(n.h3,{id:"2916-\u66ff\u6362-programcs-\u5185\u5bb9\u4e3a",children:["2.9.1.6 \u66ff\u6362 ",(0,t.jsx)(n.code,{children:"Program.cs"})," \u5185\u5bb9\u4e3a\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"var builder = WebApplication.CreateBuilder(args).Inject();\r\nvar app = builder.Build();\r\napp.Run();\n"})}),"\n",(0,t.jsx)(n.admonition,{title:"v3.6.4+ \u7248\u672c",type:"important",children:(0,t.jsxs)(n.p,{children:["\u5982\u679c\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Furion 3.6.4+"})," \u7248\u672c\uff0c\u53ef\u76f4\u63a5\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Serve.Run(RunOptions.Default);"})," \u66ff\u4ee3\u4e0a\u9762\u5373\u53ef\u3002"]})}),"\n",(0,t.jsxs)(n.admonition,{title:"\u5c0f\u63d0\u9192",type:"tip",children:[(0,t.jsxs)(n.p,{children:["\u5982\u679c\u4f7f\u7528\u4e86 ",(0,t.jsx)(n.code,{children:"Serilog"})," \u65e5\u5fd7\u7ec4\u4ef6\uff0c\u53ef\u6dfb\u52a0 ",(0,t.jsx)(n.code,{children:"builder.UseSerilogDefault();"})]}),(0,t.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"Serve.Run(RunOptions.Default.ConfigureBuilder(builder => builder.UseSerilogDefault()));"}),"\u3002"]}),(0,t.jsxs)(n.p,{children:["\u5982\u679c\u4f7f\u7528\u4e86 ",(0,t.jsx)(n.code,{children:"pgsql"})," \u6570\u636e\u5e93\uff0c\u4f60\u8fd8\u53ef\u80fd\u9700\u8981\u6dfb\u52a0 ",(0,t.jsx)(n.code,{children:'AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);'}),"\r\n=> ",(0,t.jsx)(n.a,{href:"https://www.npgsql.org/doc/types/datetime.html",children:"\u76f8\u5173\u8bf4\u660e\uff1a\u5728 .NET6 \u4e2d Npgsql 6.0 \u5bf9\u65f6\u95f4\u6233\u7684\u6620\u5c04\u65b9\u5f0f\u8fdb\u884c\u4e86\u4e00\u4e9b\u91cd\u8981\u7684\u66f4\u6539\u3002"})]})]}),"\n",(0,t.jsx)("img",{src:(0,c.Z)("img/sjl6.png")}),"\n",(0,t.jsx)(n.h3,{id:"2917-\u91cd\u65b0\u7f16\u8bd1\u6574\u4e2a\u89e3\u51b3\u65b9\u6848",children:"2.9.1.7 \u91cd\u65b0\u7f16\u8bd1\u6574\u4e2a\u89e3\u51b3\u65b9\u6848"}),"\n",(0,t.jsx)(n.p,{children:"\u5347\u7ea7\u5b8c\u6210\uff01\uff01\uff01"})]})}function h(e={}){const{wrapper:n}={...(0,r.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(p,{...e})}):p(e)}},1151:(e,n,s)=>{s.d(n,{Z:()=>i,a:()=>d});var t=s(7294);const r={},c=t.createContext(r);function d(e){const n=t.useContext(c);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:d(e.components),t.createElement(c.Provider,{value:n},e.children)}}}]);