大连站,大魔术师 电影,自由人
ef中的fluentapi作用是通过配置领域类来覆盖默认的约定。在ef中,我们通过dbmodelbuilder类来使用fluentapi,它的功能比数据注释属性更强大。
使用fluentapi时,我们在context类的onmodelcreating()方法中重写配置项,一个栗子:
public class schoolcontext: dbcontext { public dbset<student> students { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { //write fluent api configurations here } }
我们可以把fluentapi和数据注释属性一起使用,当fluentapi和数据注释属性都配置了同一个项时,采用fluentapi中的配置。
在ef6中fluentapi可以配置领域类的以下几个方面:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论