如何为一对多关系中的两个表创建一个模型 [英] How to create one model for two related tables the relations in One to Many

查看:70
本文介绍了如何为一对多关系中的两个表创建一个模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表,分别是车辆和车辆维修历史记录,需要为这两个表创建一个模型.如何实现.

一台车可能有一个或多个维修历史.以后需要针对该模型进行更新,删除和插入.

谢谢

I have two tables named vehicle and vehicle repair history, It is needed to create one model for these two tables.How will this be accomplished.

There may be one or more repair histories for one vehicle. Later need to do update,delete and insert against that model.

thanks

推荐答案

没有完全理解,但您能否简单地
-创建车辆表
-车辆表中有一个主键(例如身份或GUID)
-创建用于车辆维修的表格
-还要创建一个主键
-在车辆维修中定义外键以引用车辆表
Didn''t fully understand but could you simply
- create a table for vehicle
- in vehicle table have a primary key (for example identity or guid)
- create a table for vehicle repair
- create a primary key as well
- define a foreign key on vehiclerepair to reference the vehicle table


这篇关于如何为一对多关系中的两个表创建一个模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆