尝试运行 asp.net 核心项目时出现此错误。缺少一个或多个编译参考。确保项目引用“Microsoft.NET.Sdk.web”且 PreserveCompilationContext 属性未设置为 falseEfDemo.csproj<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> </ItemGroup></Project>家庭控制器.csnamespace EfDemo.Controllers{ public class HomeController : Controller { async public Task<IActionResult> Index() { using (var context = new EFCoreWebDemoContext()) { var model = await context.Authors.AsNoTracking().ToListAsync(); return View(model); } } }}
- 3 回答
- 0 关注
- 496 浏览
添加回答
举报
0/150
提交
取消