[英](Build Failed) Add-Migration Initial
我正在學習 .NET 課程
我需要在 PieController.cs 文件下的包管理器控制台中編寫“Add-Migration Initial”。
當我這樣做時,我收到一條沒有錯誤列表的“構建失敗”消息。
導致構建失敗的問題是什么?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BethanysPieShop.Models;
using BethanysPieShop.ViewModels;
namespace BethanysPieShop.Controllers
{
public class PieController : Controller
{
private readonly IPieRepository _pieRepository;
private readonly ICategoryRepository _categoryRepository;
public PieController(IPieRepository pieRepository, ICategoryRepository categoryRepository)
{
_pieRepository = pieRepository;
_categoryRepository = categoryRepository;
}
public ViewResult List()
{
PiesListViewModel piesListViewModel = new PiesListViewModel();
piesListViewModel.Pies = _pieRepository.Pies;
piesListViewModel.CurrentCategory = "Cheese cakes";
return View(piesListViewModel);
}
}
}
課程成績如下(1) ;
您可以執行以下操作:
可以肯定的是,某些錯誤或某些錯誤無法讓您的遷移做好准備。
在我的情況下,同樣的問題是由於我的主項目引用了另一個具有不同版本 EFCore 的問題。 所以我必須在能夠管理遷移之前刪除項目引用。 在所有鏈接的項目中使用相同的 EF 版本也應該是解決方案。
根據我的經驗,這是由其他錯誤引起的,糾正錯誤后,它起作用了。 在 _ViewStart.cshtml 中,我必須將 Layout = _Layout 更改為 Layout = "_Layout"。
在其他情況下可能是由於其他錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.