ASP.NET Core2.1迁移3.1

官方文档

2.1-2.2

2.2-3.0

3.0-3.1

迁移

打开后缀为.csproj文件(如果使用vs,右键项目-编辑项目文件),迁移之前的代码。

ASP.NET Core2.1迁移3.1

根据官方文档添加的包

    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.0" Condition="‘$(Configuration)‘ == ‘Debug‘" />

修改后

ASP.NET Core2.1迁移3.1

 

 右键项目重新生成,出现了一个错误,经过查找资料,我把<FrameworkReference Include="Microsoft.AspNetCore.App" />这个包去掉了,就解决了。

ASP.NET Core2.1迁移3.1

 

 修改Program.cs

ASP.NET Core2.1迁移3.1

 修改Startup.cs

using Microsoft.Extensions.Hosting;
#删除
public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } #添加 public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }

重新生成项目,生成文件成功。

ASP.NET Core2.1迁移3.1

 

ASP.NET Core2.1迁移3.1

上一篇:eclipse无创建web项目选项


下一篇:HTML针式打印机打印模板