0

I'm using entity framework, and imagine that I have a function where returns a table with the following columns:

  • StudentId : smallint
  • TestTemplateId : smallint
  • Date : date

As you can see, I'm returning a table with only ids. In the application I have a classes like Student and TestTemplate, I don't know if it will be possible that the function can map to complex objects.

1 Answer 1

1

What you are looking for is Entity Framework Navigation Properties. These allow you to represent foreign key relationships in your database as direct object links in your model.

Ive written an intro tutorial to code first navigation properties which is available here: http://blog.staticvoid.co.nz/2012/07/entity-framework-navigation-property.html

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I'm looking for that! So, when a create a foreign relationship, by default do I create a navigation property?
@DarfZon When i write ef I normally let EF manage database schema updates via EF migrations. This means i only need to modify my EF entity classes to add in a navigation property (which when migrations runs creates the foreign key in the database). However if you are manually performing your DB updates you can do it in both the EF Entities and database to produce the same effect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.