Arc*_*ian 15 .net c# entity-framework ef-code-first
我确信我在这里遗漏了一些简单的东西.我正在尝试遵循Code First Entity Framework教程,该教程告诉我使用一些数据注释.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace Model
{
public class Destination
{
public int DestinationId { get; set; }
[Required]
public string Name { get; set; }
public string Country { get; set; }
[MaxLength(500)]
public string Description { get; set; }
[Column(TypeName="image")]
public byte Photo { get; set; }
public List<Lodging> Lodgings { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
编译器对前两个注释没有任何问题,但它似乎不喜欢:[Column(TypeName="image")]
.
错误:
找不到类型或命名空间名称"列".
找不到类型或命名空间名称"ColumnAttribute".
我正在使用Visual Studio 2012和Entity Frameworks 5.
有什么建议?
Shy*_*yju 30
在Entity Framework 4.3.1中,ColumnAttribute
在System.ComponentModel.DataAnnotations
namspace中定义,可在其中使用EntityFramework.dll
.因此,如果你有一个对该命令行的引用和对命名空间的using语句,你应该没问题.
在Entity Framework 5中,它位于System.ComponentModel.DataAnnotations.Schema
namspace中,因此您需要在类中添加对它的引用.
using System.ComponentModel.DataAnnotations.Schema;
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读有关它的更多详细信息.