Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework MVC4唯一字段模型_Entity Framework_Ef Code First - Fatal编程技术网

Entity framework MVC4唯一字段模型

Entity framework MVC4唯一字段模型,entity-framework,ef-code-first,Entity Framework,Ef Code First,我一直在谷歌上搜索这个,没有任何乐趣 如何在mvc4.net中的代码优先方法中向字段添加unique public class Religion { public int ReligionId { get; set; } [Required] [StringLength(200)] public string Description { get; set; } } 我需要在说明中添加哪些内容才能使其工作您可以

我一直在谷歌上搜索这个,没有任何乐趣

如何在mvc4.net中的代码优先方法中向字段添加unique

   public class Religion
    {
        public int ReligionId { get; set; }
        [Required]
        [StringLength(200)]
        public string Description { get; set; }
    }

我需要在说明中添加哪些内容才能使其工作

您可以使用远程验证 回顾这一联系 简捷