本文介绍了实体框架代码首先:使用属性进行自定义映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 ScottGu的文章,他使用OnModelCreating方法来定义模式映射。我想知道如果实体框架有一些现有的功能,允许我们通过属性进行映射。例如,该文章中提到的 Dinner 类可能如下所示:
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;} }推荐答案
绝对。请参阅表和列属性: http:// msdn。 microsoft/en-us/data/gg193958
Absolutely. See 'Table' and 'Column' attributes in: msdn.microsoft/en-us/data/gg193958
更多推荐
实体框架代码首先:使用属性进行自定义映射?
发布评论