gpt4 book ai didi

c# - 奇怪的错误 : The type name 'Models' does not exist in the type . ... 播种实体数据库时

转载 作者:太空宇宙 更新时间:2023-11-03 15:23:56 25 4
gpt4 key购买 nike

我在尝试为我的实体数据库设置初始种子时收到一个奇怪的引用错误。 “SetupSheet.Models.SetupSheet”类型中不存在类型名称“Models” 我无法弄清楚。我必须有这些引用资料:

using SetupSheet.Models;
using SetupSheet.Models.CollectionofTool;

用于定义 TurningTool 对象的属性。

Error

配置.cs

namespace SetupSheet.Migrations
{
using SetupSheet.Models;
using SetupSheet.Models.CollectionofTool;
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;

internal sealed class Configuration : DbMigrationsConfiguration<SetupSheet.Models.DataModel>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}

protected override void Seed(SetupSheet.Models.DataModel context)
{
context.TurningTools.AddOrUpdate(
t => t.TurningToolShape,
new TurningTool { Id = 1, InsertRadius = .032, TurningToolShape = TurningToolShape.Diamond, CreationDate = DateTime.Now },
new TurningTool { Id = 2, InsertRadius = .064, TurningToolShape = TurningToolShape.Triangle, CreationDate = DateTime.Now },
new TurningTool { Id = 3, InsertRadius = .125, TurningToolShape = TurningToolShape.Diamond, CreationDate = DateTime.Now }

);

}
}
}

车削工具.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SetupSheet.Models.CollectionofTool
{
public class TurningTool : Tool
{
[Required]
[Display(Name = "Turning Tool Shape")]
[Index("XI_TurningToolShape_Radius_Grade", 1, IsUnique = true)]
public TurningToolShape TurningToolShape { get; set; }

[Required]
[Display(Name = "Insert Radius")]
[Index("XI_TurngingToolShape_Radius_Grade", 2, IsUnique = true)]
public double InsertRadius { get; set; }

}
}

工具.cs

using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;

namespace SetupSheet.Models
{
public class Tool
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }

[Required]
[Display(Name = "Type of Tool")]
public ToolType? ToolType { get; set; }

public string Description { get; set; }

[Display(Name = "Creation Date")]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime CreationDate { get; set; }
[Required]
[Index("XI_TurningToolShape_Radius_Grade", 3, IsUnique = true)]
public Grade Grade { get; set; }
}

public enum TurningToolShape
{
[Description("Diamond")]
Diamond = 1,
[Description("Triangle")]
Triangle = 2
}
}

最佳答案

是的,我有一个 SetupSheet 类型。我改变了它,但它不起作用。感谢 Ivan Gritsenko。

关于c# - 奇怪的错误 : The type name 'Models' does not exist in the type . ... 播种实体数据库时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36096077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com