我正在构建一个 mvc 应用程序并首先使用代码。但是当我尝试访问表时,mvc 会抛出这个错误:
Invalid object name 'dbo.Membro'.
我的上下文是:
public class JethroContext : DbContext
{
public DbSet<Area> Areas { get; set; }
public DbSet<BaseIgreja> BaseIgrejas { get; set; }
public DbSet<Igreja> Igrejas { get; set; }
public DbSet<Celula> Celulas { get; set; }
public DbSet<Membro> Membros { get; set; }
public DbSet<Distrito> Distritos { get; set; }
public DbSet<Setor> Setores { get; set; }
public DbSet<Usuario> Usuarios { get; set; }
public DbSet<Ministerio> Ministerios { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
在谷歌上搜索我找到了解决方案,但对我不起作用。
Database.SetInitializer<JethroContext>(null);
编辑我:
会员等级
Public class Membro
{
public int Id {get;set;}
public String Name {get;set;}
public DateTime DateCreate {get;set;}
}