2016-03-18 6 views
2

エンティティデータベースに初期シードを設定しようとすると、奇妙な参照エラーが発生します。 The type name 'Models' does not exist in the type 'SetupSheet.Models.SetupSheet'私はそれを把握できません。これらの参照は、TurningToolオブジェクトのプロパティを定義するためのものです。奇妙なエラー:エンティティデータベースをシードするときに型名 'Models'が型に存在しません

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

Error

Configuration.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 } 

      ); 

     } 
    } 
} 

TurningTool.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; } 

    } 
} 

Tool.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 
    } 
} 
+0

あなたは実際にタイプ 'SetupSheet'を持っていますか? –

+0

'Configuration.cs'の名前空間宣言の外側で' using'sを移動することは助けになりますか? – CodingGorilla

答えて

0

はい、私はタイプSetupSheetを持っていました。私はそれを変更し、それは仕事ではありません。 Ivan Gritsenkoに感謝します。

関連する問題