I\'m having trouble trying to map my EF 4.1 Code First model to a database. Everything works fine when the database match the code exactly, but when I try and map when the colum
How about using DataAnnotations?
[Key]
[Column("ColID", TypeName="int")]
public int DinnerID { get; set; }
You can find a full list with samples at http://msdn.microsoft.com/en-us/data/gg193958
I believe you just have to do
modelBuilder.Entity<Dinner>().Property(x => x.HostedBy).HasColumnName("colHost");
for all of your columns that you want the db column names to be named differently than their property names.
Edit: After some more searching I came across this question. Judging from that and the error you posted, it seems like the mc.Properties()
is more for splitting values into different tables, not to actually rename those table names. I think renaming will still have to be done on a manual basis.
This is again information from googling and I have no idea if I am just missing a piece to do exactly what you want :).