实体框架代码首先:使用属性进行自定义映射?

编程入门 行业动态 更新时间:2024-10-28 00:17:11
本文介绍了实体框架代码首先:使用属性进行自定义映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 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

更多推荐

实体框架代码首先:使用属性进行自定义映射?

本文发布于:2023-11-12 04:54:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   实体   框架   属性   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!