データベースに以前に作成したいくつかのテーブルがあり、いくつかのモデル クラスにマップしたいと考えています。
"SISTEMA.Voyages" => public class Voyage
"SISTEMA.Puerto" => public class Port
Entityフレームワークを使用したASP.MVC 4では、これは2つの方法のいずれかで実行できることを理解しています。ただし、どちらも解決方法がわからないエラーが発生しています。
Voyage.cs の最初の例:
[Table("SISTEMA.Voyages")]
public class Voyage
または Context.cs の 2 番目:
public class ApplicationEntities : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Voyage>().ToTable("SISTEMA.Voyages");
}
}
最初のバージョンでは、これが自動的なものであると以前に想定していたときに、このエラーが発生します。
The type or namespace name 'Table' could not be found (are you using directive or an assembly reference?)
The type or namespace name 'TableAttribute' could not be found (are you using directive or an assembly reference?)
2番目の前に、これは構成の問題であると想定していたため、予期していなかったこのエラーが発生し、本当に混乱しました。
The model backing the 'ApplicationEntities' context has changed since the database was created. Consider using Code First Migrations to update the Database.
この歴史はどこに記録されていますか?
記録として、私は Rails で次のように入力して、この種の問題に対処することに慣れています。
class Voyage
self.table_name = "SISTEMA.Voyages"
end
そして、私は C# / ASP.NET にあまり詳しくありません。最初にどこが間違っているのか誰かに言われない限り、次の 1 時間は探しているものを公開するだけです。