我创建了管理面板,管理员可以编辑和更新学生列表。数据被正确编辑,但我保存时会出错。
错误:
发生了引用完整性约束冲突:关系一端的“ApplicationUser.Id”属性值与另一端的“student.ApplicationUserID”属性值不匹配
我认为问题在于我将User.id应用于ApplicationUserID,但我不知道如何解决它。
我的学生班级如下:
public class student
{
public int Id { get; set; }
public string FirstName { get; set; }
public
使用实体框架代码-第一种方法。
假设我有两个实体类:
[Table("Objects")]
public class DbObject : IValidatableObject
{
public long Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public virtual ICollection<DbObjectProperty> Properties { get; set; }
}
[T
我在人际关系上遇到了一个问题,这是我的数据库:
users table:
id
participants table:
user_id
conversation_id
conversations table:
name
在我的用户类中
public function participants() {
return $this->hasMany(Participant::class);
}
public function conversations() {
return $this->hasManyThrough(Conver
我正试图把外键放在桌子上,但我收到了这样的信息:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'user_id
'; check that column/key exists (SQL: alter table `posts` drop foreign key
user_id)
我用迁移来做这件事
S
有人能帮我解决这个数据库错误吗?我在一个名为的表上插入数据
subjectdetails(
subjectid int primarykey,
subject varchar(50),
semid int //foreign key from the table semester
departmentid int(11) // foreign key from the table department
)
现在,当我插入一个主题时,它只在SEMID上显示如下错误:无法添加或更新子行:外键约束失败
(`studentcorner/subjectdetails`,
我有下一个db结构:
在我雄辩的模型中,我有下一个代码:
Sample.php
public function polfzms()
{
return $this->belongsToMany('App\Polfzm');
}
Polfzm.php
public function samples()
{
return $this->belongsToMany('App\Sample');
}
public function gene()
{
return $this->belongsTo('App\Ge
我与数据库中的category_id列有一个外部关系,但在删除时得到了错误。这是我的删除代码:
public function destroy($id)
{
$category = Category::find($id);
$category->delete();
Session::flash('success', 'The category was successfully deleted.');
return redirect()->route('categories.index');
}
我看