MVC 3 と EF 4.3.1 を使用しています。
クラスを POCO で作成し、メタデータを使用してプロパティに DataAnnotations を追加しています。
Scaffolding EF を使用してコントロールとビューを生成しています。
私の問題:
Web サイトをテストすると、OptionId (PK IDENTITY) が TextField として表示されます。このプロパティを非表示にして、値が自動的に作成されるようにする必要があります。
[StringLength(256)] が機能せず、ビューに ClientValidation がありません
ここで何が間違っていますか?
これについてあなたの助けをありがとう
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace MyProject.Models
{
[MetadataType(typeof(ReOptionMetaData))]
public partial class ReOption
{
private class ReOptionMetaData
{
[Key]
public int OptionId { get; set; }
[Required]
[StringLength(64)]
public string Name { get; set; }
public string Value { get; set; }
[Required]
[StringLength(256)]
public string Description { get; set; }
[StringLength(256)]
public string NoteInternal { get; set; }
}
}
}