views:

11

answers:

2

My table:

Employee
--------
Name
Age
Role int (foreign key)

How can I assign a textbox value to the Role column?

In Entity Framework 4 I would go:

Employee x = new Employee()
x.Role = textBox1.Text;

It seems I don't have the Role columns available to me.

Thanks.

A: 

You should have a Role property available. Check your relationship between Employee and Role. Rebuild the project.

Leniel Macaferi
+1  A: 

EF1 is not that much different on the code side to EF4. There should be two properties:

  • Role
  • RoleReference

In your case, you'd be setting primary key value of the latter one to avoid loading the whole Role entity.

So if you really don't see any of these, then your project maybe didn't compile and you're still looking at some older version of it, that doesn't have the Role relationship.

Robert Koritnik