简体   繁体   English

实体框架添加具有外键约束的新记录

[英]Entity Framework Adding new record with foreign key constraint

In an effort to learn the entity framework I have created two tables in a one to many relationship. 为了学习实体框架,我创建了一对多关系的两个表。 The one table (Author) has the following fields - AuthorID, FirstName, LastName. 一个表(作者)具有以下字段-AuthorID,FirstName,LastName。 The many table (Payroll) has the following fields - PayrollID, AuthorID, Salary. 多表(Payroll)具有以下字段-PayrollID,AuthorID,Salary。 I have CRUD stored procdures for insert, update and delete. 我已将CRUD存储的过程用于插入,更新和删除。 What I am tying to figure-out is how to add new payroll records to the payroll table. 我要弄清楚的是如何向工资表中添加新的工资记录。

To solve this problem I decided to move my code to Entity Framework 4 where I can have the model generate foreign key relationships. 为了解决这个问题,我决定将代码移到Entity Framework 4,在该框架中我可以让模型生成外键关系。 Thanks to all. 谢谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM