0
我正在處理asp.net web api。我正在使用現有數據庫的EF 4.1代碼優先模型。我有一個類一樣,如何在asp.net web api中的ef codefirst模型中創建自定義類
public class Tab1
{
public int ID{get; set;}
public string FirstName{get; set;}
public string LastName{get; set;}
}
和我的DbContext喜歡創造,
public class EFBarContext:DbContext
{
public DbSet<Tab1> User{ get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<Tab1>().ToTable("User");
}
}
起初,我需要從表「用戶」的所有記錄,我需要根據名字來計算全名和姓,我需要將數據返回JSON格式一樣,
{"ID":212,"firstname":"kio","lastname":"nmk","fullname":"kionmk"}
爲我創建了一個自定義類一樣,
public class Tab2:Tab1
{
public fullname{get; set;}
}
和我返回與List<Tab2>
列表中,但我得到了如下的錯誤Schema specified is not valid error 0064: Facet 'MaxLength' must not be specified for type 'mediumtext'.
我按照下面的帖子,Class Inheritance with .NET EF4.1 + MySQL但我不能算出它在我的處境。所以請指導我。