2

In ScottGu’s article, he uses OnModelCreating method to define schema mapping. I am wondering if Entity Framework has some existing feature that allows us to do the mapping through attribute. For example, the Dinner class mentioned in that article could be like:

[MapTable="tblDinner"]
public class Dinner{
  [MapColumn="colId"]
  public int DinnerID {get;set;}
}
0

2 Answers 2

4

Absolutely. See 'Table' and 'Column' attributes in: http://msdn.microsoft.com/en-us/data/gg193958

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

Comments

1

I think you are looking for 'Data Annotations' Check the following blog for more info: Data Annotations in the Entity Framework and Code First

They allow you to place attributes in your source code that will tell the Entity Framework how to do the mapping

Comments

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.