博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
EF基础知识小记四(数据库=>模型设计器)
阅读量:6657 次
发布时间:2019-06-25

本文共 1415 字,大约阅读时间需要 4 分钟。

介绍了如何创建一个空设计器模型,并如何将模型同步到数据库的表中,本文则主要介绍如何将一个存在的数据库同步到模型设计器中。为了能快速的模拟这个过程,给出一下建表语句,代码如下:

--建表脚本create table Student(    Id int not null,    Name varchar(30) not null,    Age int not null)create table Teacher(    Id int not null,    Name varchar(30) not null,    Age int not null)create table StudentTeacher(    StudentId int not null,    TeacherId int not null)create table InfoCard(    Id int not null,    [Money] int not null,    StudentId int not null)--给表添加约束--单主键约束alter table Student add constraint [PK_People]primary key clustered (Id Asc)alter table InfoCard add constraint [PK_InfoCard]primary key clustered (Id Asc)alter table Teacher add constraint [PK_Teacher]primary key clustered (Id Asc)--双主键约束(多对多)alter table StudentTeacher add constraint [PK_StudentTeacher]primary key clustered (StudentId,TeacherId Asc)--双外键约束(多对多)alter table StudentTeacheradd constraint [FK_StudentTeacher_Student]foreign key (StudentId) references Student (Id) on delete no action on update no action --级联更新级联删除alter table StudentTeacher add constraint [FK_StudentTeacher_Teacher]foreign key (TeacherId) references Teacher (Id) on delete no action on update no action --但外键约束(一对多)alter table InfoCard add constraint [FK_InfoCard_Student]foreign key (StudentId) references Student (Id) on delete no action on update no action

 

1、看过后,省去一些简单的操作步骤,直接到下面这步操作

根据数据库生成edmx

2、选择指定的数据库,并选择响应的表生成edmx模型设计器

3、点击确认,生成成功,如下图:

 

 4、增删查该的操作和介绍的一样

转载地址:http://qmtto.baihongyu.com/

你可能感兴趣的文章
Oracle 11g 安装
查看>>
Python常用模块
查看>>
[LeetCode]: 121: Best Time to Buy and Sell Stock
查看>>
探索Google App Engine背后的奥秘(6)- 总结(转载)
查看>>
周总结
查看>>
BFC和清除浮动
查看>>
linux命令之grep命令
查看>>
多肉淘宝养成记(含治疗玻璃心)
查看>>
Core Java - 流(Stream) - 字节流和字符流(一)
查看>>
day3.字符串的索引与切片
查看>>
javaweb 字符集
查看>>
FBV和CBV装饰器
查看>>
android toolbar 显示返回按钮并改变按钮颜色
查看>>
call() apply() bind() 异同
查看>>
高级程序员职责
查看>>
matlab 直方图均衡化(含rgb)
查看>>
13个Cat命令管理(显示,排序,建立)文件实例
查看>>
2019年今日头条机试_JAVA后台岗_第二题
查看>>
java生成解析xml的另外两种方法JAXB
查看>>
使用Spring配置数据源JdbcTemplate
查看>>