I have a few tables previously created in my database that I want to map to a few model classes:
"SISTEMA.Voyages" => public class Voyage
"SISTEMA.Puerto" => public class Port
I understand that in ASP.MVC 4 with Entity framework this can be done either of two ways. However for both of them I am getting errors which I do not know how to resolve.
The first in Voyage.cs:
[Table("SISTEMA.Voyages")]
public class Voyage
Or the second in Context.cs:
public class ApplicationEntities : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Voyage>().ToTable("SISTEMA.Voyages");
}
}
For the first version I get this error when I previously assumed this was something automatic:
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?)
Fore the second I get this error which I didn't expect because I assumed this was a configuration issue and leaves me really confused:
The model backing the 'ApplicationEntities' context has changed since the database was created. Consider using Code First Migrations to update the Database.
Where is this history even recorded?
For the record, I am used to dealing with this sort of issue in Rails by typing in:
class Voyage
self.table_name = "SISTEMA.Voyages"
end
And I am not very familiar with C# / ASP.NET. Just publishing what I am looking up for the next hour unless somebody tells me where I am going wrong first.