ショッピングリストアプリケーションを作成しようとしていて、ショッピングリストエンティティとショッピングリストアイテムエンティティがあります。ショッピングリストには、IDキーと、関係のないいくつかの余分な変数が含まれている必要があります。ショッピングリストアイテムは、そのショッピングリストのIDに関連するIDキーおよび外部キーを有するべきである。これをどうやってやりますか?私はUpdateDatabaseExceptionを取得しています。あなたはクラスがちょうど頼むもう必要がある場合、またはこれを行うには良い方法がある場合、私はどのように外部キーを使用して別のテーブルのIDに関連付ける方法
ShoppingList
public class ShoppingList
{
[Key]
public int Id { get; set; }
}
ShoppingListItem
public class ShoppingListItem
{
[Key]
public int Id { get; set; }
[ForeignKey("ShoppingList")]
public int ShoppingListId { get; set; }
{
学習いただければ幸いです。私はこのスレッドに私は私は完全に間違っていた
"The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_dbo.ShoppingListItem_dbo.ShoppingList_ShoppingListId\". The conflict occurred in database \"ShoppingListApp\", table \"dbo.ShoppingList\", column 'Id'.\r\nThe statement has been terminated."
もう奇妙なエラーが発生しました。悪い更新スレッド – haseo256