ASP.NET を使い始めたのですが、問題があります。Visual Studio で MVC4 アプリケーションを作成しました。次に、モデルに、最初にデータベースを使用する方法で ADO.NET エンティティ データ モデルを追加しました。エラーメッセージが表示されたときに新しいコントローラーを追加しようとするまで、すべて問題あり'Projectname.Models.Tablename' is not part of specified 'Projectname.Models.Contextname' class and the 'Projectname.Models.Contextname' class could not be modified to add a DbSet<Projectname.Models.Tablename> property to it.
ません。私の間違いは何ですか?
ここに私の生成されたモデルがあります:
public partial class Example
{
public int ID { get; set; }
public string Name { get; set; }
}
生成されたコンテキストは次のとおりです。
public partial class TestEntities : DbContext
{
public TestEntities()
: base("name=TestEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Example> Example { get; set; }
}