問題の性質と現在の設定をもう少し詳しく知りたい場合があります。
私は本当に簡単なプロジェクトを設定する前にLINQを実際に使いこなしていません。私は2つの別々のテーブルにGUIDを挿入できました。
Dim db As New testDBDataContext
' Table1 ID (Primary Key)
Dim gId As Guid = Guid.NewGuid()
' Table2 ID (Primary Key)
Dim gId2 As Guid = Guid.NewGuid()
' Insert Record into Table 1
Dim tb1Insert As New test_tb1 With {.Id = gId, .Name = "TestName"}
db.test_tb1s.InsertOnSubmit(tb1Insert)
' Insert Record into Table 2, with testID referenced to Table1's Primary Key
Dim tb2Insert As New test_tb2 With {.Id = gId2, .test1Id = gId, .OtherName = "OtherName"}
db.test_tb2s.InsertOnSubmit(tb2Insert) '
' Commit Changes
db.SubmitChanges()
エラーが発生する唯一の方法は、SQL Serverで2つのテーブルの間に関係を設定する場合です。次に、テーブル2に最初に挿入しようとすると、GUIDテーブル2の "test1ID" w/oをテーブル1に挿入しようとしているため、エラーが発生します。
「COLUMN FOREIGN KEY制約と競合しました」というエラーが発生している可能性があります。