实体框架代码首先:使用属性进行自定义映射? [英] Entity Framework Code First: Custom Mapping Using Attribute?
本文介绍了实体框架代码首先:使用属性进行自定义映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 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.com/en-us/data/gg193958
Absolutely. See 'Table' and 'Column' attributes in: http://msdn.microsoft.com/en-us/data/gg193958
这篇关于实体框架代码首先:使用属性进行自定义映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文