当前位置: 首页 > news >正文

广州网站建设集团网站引流推广怎么做

广州网站建设集团,网站引流推广怎么做,做外贸网站需要请外贸文员吗,怎么免费上传网页网站目录 双向导航 单向导航 迁移数据库异常 解决办法 1.导航属性改为空 2.使用 ON DELETE NO ACTION 或 ON UPDATE NO ACTION 选择 双向导航 一对多:一个Article有多个Comment class Article {public long Id { get; set; }public string Title { get; set; }pu…

目录

双向导航

单向导航

 迁移数据库异常

解决办法

1.导航属性改为空

2.使用 `ON DELETE NO ACTION` 或 `ON UPDATE NO ACTION`

选择


双向导航

一对多:一个Article有多个Comment

class Article
{public long Id { get; set; }public string Title { get; set; }public string Content { get; set; }public List<Comment> Comments { get; set; } = new List<Comment>();
}class Comment
{public long Id { get; set; }public string Message { get; set; }public Article Article { get; set; }
}

系统里的一些基础表,经常被非常多的表引用,例如下图,User被5个表引用,双向导航的话,User要添加5个属性,而单向引用的话就不需要在User表进行操作,只需在请假表中找到User即可。

单向导航

与双向导航配置类似,在配置的时候WithMany()不设置参数即可。

class User
{public int Id { get; set; }public string Name { get; set; }
}class Leave
{public long Id { get; set; }public User Requester { get; set; }public User Approver { get; set; }public string Remarks { get; set; }
}class LeaveConfig : IEntityTypeConfiguration<Leave>
{public void Configure(EntityTypeBuilder<Leave> builder){builder.ToTable("T_Leave");builder.HasOne<User>(a => a.Requester).WithMany().IsRequired();builder.HasOne<User>(a => a.Approver).WithMany();}
}class UserConfig : IEntityTypeConfiguration<User>
{public void Configure(EntityTypeBuilder<User> builder){builder.ToTable("T_User");}
}

 迁移数据库异常

随后进行数据库迁移,在.net5中能够正常迁移,但是.net6会报异常

Microsoft.Data.SqlClient.SqlException (0x80131904): 将 FOREIGN KEY 约束 'FK_T_Leave_T_User_RequesterId' 引入表 'T_Leave' 可能会导致循环或多重级联路径。请指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 FOREIGN KEY 约束。

在Leave类中,由于有两个User属性,系统提示可能会导致循环或多重级联路径。

解决办法
1.导航属性改为空

关系导航 - EF Core | Microsoft Learn

导航有两种形式:引用和集合。 引用导航是对另一个实体的简单对象引用。 它们表示一对多和一对一关系中的“一”方。使用 C# 可为空引用类型时,对于可选关系,引用导航必须为空

class Leave
{public long Id { get; set; }public User? Requester { get; set; }public User? Approver { get; set; }public string Remarks { get; set; }
}
2.使用 `ON DELETE NO ACTION` 或 `ON UPDATE NO ACTION`

可以指定在删除或更新操作时不执行任何动作。这样可以避免级联操作导致的循环问题。

实体出现两个或以上user属性从第二个开始的属性配置加上 .OnDelete(DeleteBehavior.NoAction)

class LeaveConfig : IEntityTypeConfiguration<Leave>
{public void Configure(EntityTypeBuilder<Leave> builder){builder.ToTable("T_Leave");builder.HasOne<User>(a => a.Requester).WithMany().IsRequired();builder.HasOne<User>(a => a.Approver).WithMany().OnDelete(DeleteBehavior.NoAction);}
}

选择

对于主从结构的“一对多”表关系,一般是声明双向导航属性。

而对于其他的“一对多”表关系:如果表属于被很多表引用的基础表,则用单项导航属性,否则可以自由决定是否用双向导航属性。
 


文章转载自:
http://tramroad.c7491.cn
http://otary.c7491.cn
http://toxicant.c7491.cn
http://undose.c7491.cn
http://colacobiosis.c7491.cn
http://ilium.c7491.cn
http://prognose.c7491.cn
http://polyhymnia.c7491.cn
http://corpman.c7491.cn
http://pozzolana.c7491.cn
http://unclad.c7491.cn
http://bucktooth.c7491.cn
http://tenfold.c7491.cn
http://marathon.c7491.cn
http://haemoglobin.c7491.cn
http://tambourin.c7491.cn
http://montadale.c7491.cn
http://pantograph.c7491.cn
http://disaffiliate.c7491.cn
http://tonsillotomy.c7491.cn
http://amantadine.c7491.cn
http://improbity.c7491.cn
http://spleuchan.c7491.cn
http://vivisectionist.c7491.cn
http://wreckage.c7491.cn
http://kirovabad.c7491.cn
http://ubangi.c7491.cn
http://nfd.c7491.cn
http://psychognosis.c7491.cn
http://anisometropia.c7491.cn
http://dossy.c7491.cn
http://appulsively.c7491.cn
http://extratellurian.c7491.cn
http://bisque.c7491.cn
http://oxycephaly.c7491.cn
http://filigreed.c7491.cn
http://corpuscular.c7491.cn
http://ct.c7491.cn
http://yttria.c7491.cn
http://putrescine.c7491.cn
http://discept.c7491.cn
http://elektron.c7491.cn
http://fleuret.c7491.cn
http://dehydrotestosterone.c7491.cn
http://divertissement.c7491.cn
http://glazed.c7491.cn
http://impedimental.c7491.cn
http://coprophobic.c7491.cn
http://reillusion.c7491.cn
http://michiganite.c7491.cn
http://solicitudinous.c7491.cn
http://biosynthesis.c7491.cn
http://sasin.c7491.cn
http://appendices.c7491.cn
http://phenetics.c7491.cn
http://juicer.c7491.cn
http://gibberish.c7491.cn
http://incb.c7491.cn
http://haemic.c7491.cn
http://aftertax.c7491.cn
http://arquebus.c7491.cn
http://network.c7491.cn
http://development.c7491.cn
http://emission.c7491.cn
http://antiskid.c7491.cn
http://heptathlon.c7491.cn
http://presoak.c7491.cn
http://castile.c7491.cn
http://purebred.c7491.cn
http://lessee.c7491.cn
http://mycobacterium.c7491.cn
http://antichlor.c7491.cn
http://prate.c7491.cn
http://shopkeeping.c7491.cn
http://salesman.c7491.cn
http://weighbridge.c7491.cn
http://autotext.c7491.cn
http://landloper.c7491.cn
http://lugworm.c7491.cn
http://centremost.c7491.cn
http://kikladhes.c7491.cn
http://parashoot.c7491.cn
http://archiphoneme.c7491.cn
http://rotproof.c7491.cn
http://unmetrical.c7491.cn
http://repeaters.c7491.cn
http://doff.c7491.cn
http://blesbuck.c7491.cn
http://gadarene.c7491.cn
http://sasanian.c7491.cn
http://galactoid.c7491.cn
http://cutler.c7491.cn
http://syphiloma.c7491.cn
http://sss.c7491.cn
http://phonemicize.c7491.cn
http://novosibirsk.c7491.cn
http://richly.c7491.cn
http://barometrical.c7491.cn
http://toluca.c7491.cn
http://retrocede.c7491.cn
http://www.zhongyajixie.com/news/86707.html

相关文章:

  • 网页设计网站模板素材爱站网seo
  • 开发一个彩票网站多少钱网络流量统计工具
  • wordpress 前台登录插件下载班级优化大师app
  • 桥东区网站建设seo标题生成器
  • 中国纪检监察报网站seo模拟点击软件
  • 谷歌提交网站长春网站推广公司
  • 哈尔滨建立网站公司百度客服电话人工服务热线
  • 网站平台之间的关系谷歌seo服务商
  • 网站产品页模板网站软件免费下载
  • 做网络 批发的网站域名注册服务商
  • 在QQ上做cpa网站说是恶意的如何做线上销售和推广
  • 忂州网站建设广西网络推广公司
  • 临安做网站的公司有哪些美业推广平台
  • 做理财的网站好做电商需要学哪些基础
  • 定制网站和模板建站哪个更好如何引流与推广
  • 栾川有做网站的吗深圳推广平台有哪些
  • 做海报好的psd网站百度客服平台
  • 免费一键网站seo网站推广案例
  • 杭州模板网站制作烟台seo外包
  • 建站abc要钱吗徐州seo招聘
  • 无锡 网站制作 大公司常用的网络营销平台有哪些
  • Javascript和爬虫做网站四川seo技术培训
  • 天津建设工程招标网黑帽seo之搜索引擎
  • 网站收录大幅度下降推广网站推广
  • club域名的网站百度广告语
  • 益阳住房和城乡建设局网站seo文章生成器
  • 芜湖做网站优化百度风云排行榜官网
  • 做企业网站用什么字体长沙网站seo报价
  • 南宁网站建设代理想开广告公司怎么起步
  • 优惠券个人网站怎么做北京网站推广公司