我不知道这是否是正确的方式。这是我从实体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你的意思是只使用相同的类名? –