我不知道這是否是正確的方式。這是我從實體6.XX生成類:將班級另存爲另一個班級
namespace bd.inputdata.edmx
{
using model;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
[MetadataType(typeof(Usuario))]
public partial class input_usuario
{
public int id { get; set; }
public string nome { get; set; }
public string usuario { get; set; }
public string senha { get; set; }
public string email { get; set; }
public int id_grupo { get; set; }
public System.DateTime data_criacao { get; set; }
public System.DateTime data_alteracao { get; set; }
public Nullable<int> tipo { get; set; }
public byte ativo { get; set; }
}
}
我已經創造了另一個類的數據anottions,如圖here。
using System;
using bd.inputdata.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace bd.inputdata.model
{
[Table("usuario")]
public class Usuario : IRaizDeAgregacao
{
[Key]
public int id { get; set; }
[Required]
[StringLength(150)]
public string nome { get; set; }
[Required]
[StringLength(100)]
public string usuario { get; set; }
[Required]
[StringLength(100)]
public string senha { get; set; }
[Required]
[StringLength(50)]
public string email { get; set; }
[Required]
public int id_grupo { get; set; }
[Timestamp]
public DateTime data_criacao { get; set; }
[Timestamp]
public DateTime data_alteracao { get; set; }
public int? tipo { get; set; }
public byte ativo { get; set; }
}
}
當我試圖在這個新類Usuario,它說我不能上下文保存:
那麼,什麼是糾正這一點的最好方法是什麼?
嘗試以下操作: 變化'公共類Usuario:IRaizDeAgregacao'到'公共部分類input_usuario:IRaizDeAgregacao' – Eon
@Krohn不能屬性的屬性通過部分類添加。 –
@Krohn你的意思是隻使用相同的類名? –