我正在試驗 Visual Studio 2022 和 EF Core 6。我創建了一個包含三個專案的解決方案,一個包含我的剃刀頁面,一個包含我的 dbcontext,一個包含我的物體。我能夠毫無問題地進行遷移,創建資料庫和單個表,這對我來說表明我一切正常,但是當我添加一個剃刀頁面并允許 VS 為我連接一個“串列”模板時,它旋轉一分鐘并給我一個錯誤:名稱為 Scaffolding.Entities.EncylopediaEntry 的型別不存在。
這是顯然不存在的類
using System.ComponentModel.DataAnnotations;
namespace Scaffolding.Entitites
{
public class EncylopediaEntry
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
}
這是現在帶有硬編碼連接字串的 DbContext 因為我試圖找出為什么腳手架不起作用
using Microsoft.EntityFrameworkCore;
using Scaffolding.Entitites;
namespace ScaffoldingTest.Data
{
public class ScaffoldingContext : DbContext
{
public DbSet<EncylopediaEntry> encyclopediaEntries { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("{remove}");
}
}
}

uj5u.com熱心網友回復:
我有同樣的錯誤。帶有 NET 6.0 的 Visual Studio 2022(也是預覽版)。我安裝了 NET 5.0 并使用新專案 net 5 進行了測驗,然后運行良好。但不是 NET 6.0。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/360519.html
