首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

EntityFramework 如何建几个结构一样的表

2013-09-08 
EntityFramework 怎么建几个结构一样的表public class Category{public string CategoryId { get set }p

EntityFramework 怎么建几个结构一样的表

  public class Category
    {
        public string CategoryId { get; set; }
        public string Name { get; set; }
    }

  public class ProductContext2 : DbContext
    {
        public DbSet<Category> Categories1 { get; set; }
       public DbSet<Category> Categories2 { get; set; }
    }

这样出错.
[解决办法]
有没有试过继承类

 public class Category1: Category
    {
       
    }

 public class ProductContext2 : DbContext
    {
        public DbSet<Category1> Categories1 { get; set; }
       public DbSet<Category2> Categories2 { get; set; }
    }

 
[解决办法]
引用:
  public class Category
    {
        public string CategoryId { get; set; }
        public string Name { get; set; }
    }

  public class ProductContext2 : DbContext
    {
        public DbSet<Category> Categories1 { get; set; }
       public DbSet<Category> Categories2 { get; set; }
    }

这样出错.


为什么要建结构一样的表?说说你的应用场合。

热点排行