I dont want to include relations in my edmx entity framework, I mean i want to have the foreign key field as a normal property in my entity. how can i do that?
having the same problem, my quick fix was Right click on table in edmx (actually right click the word scalar properties), add scalar property, name it SomeId, goto table mapping at the bottom of the screen, and map the two values. There's a reason the entity framework doesnt allow this kind of access by default, there should be a better way of doing this, a pattern of some kind we should be following, maybe someone will reply and enlighten us.
i take it back, this doesnt work!!!
http://www.thedatafarm.com/blog/2007/09/11/EntityDataModelAssociationsWheresMyForeignKey.aspx
I found the article describing the error in our ways... basically we never supposed to be querying tables via foreign keys instead take a bit more relational approach (From o In nw.Orders Where o.OrderID = 10281 Select o.Customers).First
i take it that ure trying to access a table say "Contact" that has a foreign key "SubscriberId" in it, now say you want to add a Contact with Foreign key 1, example below instead of hacking away at edmx.
using (BulkSmsEntities ctx = new BulkSmsEntities())
{
int SubscriberId = 1;
tb_contact contact = new tb_contact();
contact.tb_subscriber = ctx.tb_subscriber.First(a => a.SubscriberId == SubscriberId);
ctx.AddTotb_subscriber_contacts(contact);
ctx.SaveChanges();
}