0
我使用實體框架來保存多對多關係。 很明顯,部分關係已經在數據庫中出現了,它給了我一個重複的KEY錯誤。更新多對多關係 - 實體框架
如何使插入的實體框架覆蓋?
我的錯誤:
System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK__PaymentL__3214EC07CE1C6DCF'. Cannot insert duplicate key in object 'dbo.PaymentLine'. The duplicate key value is (47c78fb5-b536-4920-b7e6-c925e9879aee).
我的一個表是這樣的:
CREATE TABLE [dbo].[PaymentLine](
[Id] [uniqueidentifier] NOT NULL,
...
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]