EF 主键自增、级联删除
一、主键自增
1.设置数据库中,主键自增
2.设置VS中Model1.edmx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAioAAAFPCAIAAADsg3KQAAAgAElEQVR4nO2d/W9c13nnL2BLFEn3L9ACCwMLZNVudrtrIK3Hrhqy7P6wIMsiSFrZadcqk84CBGoWYQu/BG0Vg2p2y13vSGYYqYyzaSSQaRg7qWkNmTi0bLphGGpsmbRsSh65YixbsWi98G2oqJJ494dzX87bvXNfzpl778z3gy8M8vLOULry3M8855w5j/H/np9BEARBkBrH+MnpCwiCIAhS40A/CIIgSAKBfhAEQZAEAv0gCIIgCQT6QRAEQRKI8au5P0ht9tz/OaTOEuf/h6dHfty1/yk33yybCxNd+ydOXZ77kn3k0g+/Qf77pR9evfTDb3Ttf6rrK3OXnBP2P9W1/6kv/fDqqW8+xTwVgmQqZl0A/SA1jUL9HF64+oOvPGXp5ytzl4T/uS3HEP18syx/BbBmQpBMRLMXagT0g9Q0CvWDIA2bpMWhBugHqWmgHwSJn6TFoQbjV3N/mNokfq9ElCfO/w/QD4KQJC0ONRjm+rMIksJAPwjilaTFoQboB0lpoB8E8UrS4lCDsQ2AZj766ErYPD3yY+gHQbyStDjUYCT9BwD1j0L9JP1XAQAoA/oB2oF+AAAi0A/QTkT9PPCHXKAfAOoJ6AdoB/oBAIhAP0A70A8AQAT6Adrxcszf/q+j0A8ADQv0A7Tj5R6S9OinmDcMI1fw2JvULBdyhmEY+aLWPwQADQP0A7Tj4x4vA4XRTzFvEGgxWK4IZYsw+nGeX/obuGciJ9vfUw+1Dzp/Bfop+YOSx4f51e7T5Yvik7N/cf9fITsNWgbhgX6AdvzdIzVQJP1Qd0D3xqhHP/SNN5R+mDt2OP1Yx6P+6mr6oZ6wyq+grwjtRO9Lp5hyIQfb1QPQD9BOVfeIBgqtn1wuR90ry4Ucf4i54VL3LqpMYu/c7vnWIXHwjRwJpR/yrO6fM0/ph3si5iD5hn/KcIUX/YT889l/W0ohnr+C/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3d8jB12O3DAGjnh9UPdlVxp0Tcj6eCbma3J6saKXD8mW/2QNyvOv2Ag/VAVT2IjbyvQD1CBXv1MT0+vrl6nlXPs2992PMTrZ2m4g3UK86No+vEbfJPM+ijRz+wotUaAqXvs+8v5k4dHz5C6x9aPe5exBu6YyoYuquhhPUz/pDWB9UP5g/rfgH/XQi8zsR+V3MjbCvQDVKBFP3Nzc6Ojo5VKZXR0dG5ujhiIHn87d+5steqnRvoRZRNXP/PjB545ecJZ+TYq08+quWJZSix0nHkjj+qHCaqf1ObM8QPSf7Jg+nFPlvz7kjG3BEfeVqAfoAIt+uns7BwZGalUKiMjI52dnRsbG071Q4/CSeZ+rKkfwUHZ0c/s6PgsvfRAWv2Qr8kSuAPjs576kc/9uEn0/S/in6WpYaZUlax8i6gfMgB7ONHCF/oB8VGvnwsXLrS1tTn6aWtro/UTZOWbtXiAdkh29ENC60cy90Pfd+bHD4yOy+Z+PFe+ucHKt5SH/ten1wswSw+c8wPrhwzGJrrqBPoB8dFV/TjjbJ2dndPT0+E/dsoKhncK/32a9SNWP8InRqXVT9WFbZj4QRIL9APio2vuhxios7Nzbm4u6MOm+ihv+OuHVEjOEXbJXOCVb/r0oyo+4/vY9QBJMNAPiI+ulW9k2I0MwQWH/syOYBt+Qsj9iJDBmyrY537kK99i73qAIPUf6AfEJ1360UHYz/3IAv0gCBPoB8RHl35GR0fb2trI8utkQbs5BFEe6AfEBw0XoB8ECR3oB8QH+oF+ECR0oB8QH7l+Ll3bqJtAPwiiPNAPiI9cP/UU6AdBlAf6AfGBfqAfBAkd6AfEB/qBfhAkdKAfEB/oB/pBkNCBfkB8oJ/ttY3ttY07a+Jx8qP17bV16AdBmEA/ID68fgAAAIAaAP0AAABIAOgHAABAAkA/AAAAEuD/AzlhIZ/3qNr2AAAAAElFTkSuQmCC" alt="" />
二、级联删除
使用Data Annotations:
如果我们要到一对主从表增加级联删除,则要在主表中的引用属性上增加Required关键字,如:
public class Destination
{
public int DestinationId { get; set; }
public string Name { get; set; }
public string Country { get; set; }
public string Description { get; set; }
public byte[] Photo { get; set; }
public List<Lodging> Lodgings { get; set; }
} public class Lodging
{
public int LodgingId { get; set; }
public string Name { get; set; }
public string Owner { get; set; }
public bool IsResort { get; set; }
public decimal MilesFromNearestAirport { get; set; }
[Required]
public Destination Destination { get; set; }
}
可以看到,在生成的数据库中,外键应用了级联删除规则
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4QAAAB2CAIAAAAfnsrjAAAbVElEQVR4nO2dO2scy7bH+4M49GdQMB9BkT+CogGnChQrEwYHSgwGJc7FiS4I7jWCndxX4n22z8EYhL0fzg4YZGRjDIY+QU93r6pa9eqp1+r5/6hgpqemetWq17+rqru7/3r7r//87V///evvCAgICAgICAgICIVDx4rRe5Vnz198+/btPeH8/PyXX37p+74jDF97lfPz867r3nPQ40MK7PHYI+7I79+///bt27PnL8xMdZF4M+W1ltpsy0VUft+/f//s+Yu+Acya4ODZ8xesMyeGWmTz+f4FEetqm/NtVUuzpFcbTmC+0jaQ8BrlzlTX9VMIOW7LVGBOTYNTlemQzXsAAAABJNYM4WL0HWESo14GGfHOwjQYD5/Z4+ZPIXFsKb97944OrjZ7QvBmKiRHmpFsBLcHtLNXF6ODVVF/efb8hc2ZmgO90dwFEVKRzCPhzndULZrC4CXtc0h2QnJhy5et7pkZj8oUFZ0hx22ZCs/pO6NROEowPLMQowAAEE5i5RAoRr9+/fpPwnkMXdf9syW+fv06DK5aptZBdTG6gGfPX9R2WxpCqtakiobPfd+31kA03JnquvMphBwvTLhvh2xW6dMBAEAcaWVAhBh9S+giedsSdHCtbUt6hIrR2m5LQ2zVmsRobsP2wZEpqjiH4D5ehmU9D8QoAACEk1YGhIrRh4eH39bCw8PDMLiuKVMTQsVobbelIbZqTZopt2H7sO72MjFks0qfDgAA4kgrAyLE6K9rgQ6utW1Jj1AxWtttaVhl1VplpkwgRgEAIJy0MsAjRodBCEFWSFtFClDdYwgICAgICAjhIa0M8IvRtOcDAAAAA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o2Q/LwVmVfrj6sjsypnB6Ro8AAIAIIEYBACCY12efT28HTfn59Lb/cPXl+Orn+COvLxUxStIhf+wXiVF6uukUzLkAAKBtIEYBACCMSXpOUpJqSnWestemTk9vf758wj2WaPeXeDF6+zCu0f98+UQTwdCjAABBQIwCAEAQRE2OOzVfn02ftWnR3j4zyk5eRovR3Rxtb9G4j7WZVwAAaBaIUQAAiODHKblJ6PXZeI/Rx+/H+rbRYDFK/suFL8dPLDOjjx9Oz9hdqruzQI8CACQAMQoAAKFo058/Xz75fHz2cKzeRTRGUJfpr2yKc7odKvoGJtvGUwAAEMVOjP7/279oqG0VAAC0x4erL0REPrzezXHOWzbN29u5mdEfp/NW0V6LHH83/QN7U7/21CcAAGgYiFEAAFjG9Jymj9+Pn3z/8FF5jKhVjN4+PHry5Vh/IKiiO0dRG/Vopx4zowAAmUCMAgBAOOP+TiIZ+36cNLU9rYncOL8TprqOHHXtJEaPr366xKiyxD+J3SG+dnM9AAA0DsQoAAAEMewBHWc06TzopA6VNXrloU7DzCh565I5Xfr9wyhGxzvl1ZlOY2a0H9MZRbDyQH7cvQQAEALEKAAARDNJwOHJSjvJON9cb0Q+vR00K1mdH5+c32sPLj17YN/SNE+mEjGq3sOk3U2P+VEAgAhGMfqPv2iobRUAADQM2dNp3Ip0+/BIf+b8z5dPPp+ePXAvjh8eUD88Lmo3mXr85MtuD8A4ETst9O90pzIzOp8UNy0BAGQCMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKoBMQoAAAAAAKrxb6k9/U61EYqTAAAAAElFTkSuQmCC" alt="" />
使用Fluent API:
modelBuilder.Entity<Lodging>().HasRequired(l => l.Destination).WithMany(d => d.Lodgings).WillCascadeOnDelete(true);
相对应的,如果要关闭级联功能则为:
modelBuilder.Entity<Lodging>().HasRequired(l => l.Destination).WithMany(d => d.Lodgings).WillCascadeOnDelete(false);
EF 主键自增、级联删除的更多相关文章
- oracle主键自增
oracle主键自增 1建立数据表 create table Test_Increase( userid number(10) primary key, /*主键,自动增加*/ ...
- for循环往Oracle中插入n条数据,主键自增
1.主键自增实现方法:http://www.cnblogs.com/Donnnnnn/p/5959871.html 2.for循环往Oracle中插入n条数据 BEGIN .. loop insert ...
- erlang mnesia数据库设置主键自增
Mnesia是erlang/otp自带的分布式数据库管理系统.mnesia配合erlang的实现近乎理想,但在实际使用当中差强人意,总会有一些不足.mnesia数据表没有主键自增的功能,但在mnesi ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'portal.hibernate_sequence' doesn't exist, 谈谈主键自增的方式
最近几天几天做项目用到了Spring Data JPA,确实是个好东西,省了很多力气.但是由于刚开始用,也遇到不少头疼的问题,如下,调用JpaRepository接口的save方法保存一个对象到数据库 ...
- oracle 主键自增 设置----杜恩德
<div id="topicList"> <div class="forFlow"> <div class = "pos ...
- psql 关于主键自增的问题
在psql中往往我们需要设置一个自增的主键id字段,psql中不像SQL Server那样点选 打钩傻瓜式就能设置好的,是需要创建序列的:CREATE SEQUENCE,关键字SEQUENCE. 我们 ...
- mysql数据库单表只有一个主键自增id字段,ibatis实现id自增
mysql数据库单表只有一个主键自增id字段,ibatis实现id自增 <insert id="autoid"> insert into user_id ...
- postgresql + mybatis insert主键自增方法
postgresql + mybatis插入记录时设置自增主键方法: 一.数据库设置主键自增 1.数据库中id字段选择serial4类型后,会在默认值中生成 nextval('app_id_seq': ...
- 关于oracle设置主键自增的问题
关于orcale设置主键自增的问题 关于主键Oracle中并没有提供一个直接的语句设置,对于这个oralce一般都是用序列和触发器来实现 一下又两种方法来实现 一 ,不使用触发器 创建序列: crea ...
随机推荐
- [置顶] android开发之来电自动拒接并自动回复短信_上课模式app
上课的时候老师说总是错过电话,对方打来没人接还一遍遍的打,觉得可以有个app在上课期间自动拒接电话,并自动回复短信过去. 当然了,需要权限的. 尝试做了个雏形出来. 界面如下: 主要代码如下: pac ...
- java特权制度设计篇
数据库表设计 1.1.1. 模块管理(jk_module) 项 类型 说明 id long 就是数据库记录idx号 name string 模块名称 orderid int 排序id 由小到大显 ...
- Oschat IM 开源即时通讯项目介绍 - FengJ的个人页面 - 开源中国社区
Oschat IM 开源即时通讯项目介绍 - FengJ的个人页面 - 开源中国社区 Oschat IM 开源即时通讯项目介绍 255人收藏此文章, 我要收藏 发表于5天前(2013-08-28 ...
- 警惕!iPhone 6即将上市 诈骗邮件已现身网络
随着iPhone 6即将上市,各路小道消息已经開始满天飞.就在近几日,一些记者还收到了假的iPhone 6将要上市的通知邮件.趋势科技也收到了几封,下面是样本之中的一个: (垃圾邮件样本) 不清楚iP ...
- Java中的工具类和新特性
1:Collections集合框架工具类: /* 集合框架的工具类. Collections:集合框架的工具类.里面定义的都是静态方法. Collections和Collection有什么差别? Co ...
- 基于HTTP和TFTP的PXE批量自动化安装Linux系统
CentOS 6.5 PXE自动化部署系统 拓扑图如下: 步骤: 1. 安装http服务,上传ISO文件 [root@UCS-1 ~]# yum install httpd –y [root@UCS ...
- 使用ILmerge合并Exe、Dll文件的帮助类
原文:使用ILmerge合并Exe.Dll文件的帮助类 using System; using System.Collections.Generic; using System.Text; using ...
- 智能生活 “视”不可挡——首届TCL杯HTML5智能电视开发大赛等你来挑战
http://www.csdn.net/article/2014-06-04/2820063-TCL-Smart-TV-Innovation-Competation
- c语言输入输出函数
上学年学习c语言的时候比较匆忙,没好好吸收. 现在有时间好好复习下. 本文就c语言常见输入函数进行简单介绍,对比. ps:由于自己能力有限,时间有限,多数介绍,总结都是摘录网上相关学习资料,下面给出本 ...
- 【LeetCode】Reorder List 解题报告
Given a singly linked list L: L0→L1→-→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→- You must do th ...