I’m new to the entity framework; working on my first app using it. So far, I love it! I really like the strongly typed way of interacting with fields in the table/query in the context of EF.
However, I’m wondering if there’s a way of accessing the fields of a table/query, the old fashion way, by naming the field as a string? For example, assuming that efObject is some table in the .EDMX, is there a way of doing something like this:
efObject["FirstName"].Value = "Fred";
If there is such a way of doing this, I don’t know what the properties are, what the methods would be, etc.
I’m working with EF 4.2.
The EF data model definition can’t be easily accessed at runtime.
Have a look at this discussion for reasons and possible workarounds: Get Database Table Name from Entity Framework MetaData
If the property name and the respective field name match, you could use reflection to deduct the mapping.