C
C#7mo ago
Lyon

Errors working with Entity Framework

Could someone help me because im currently at a deadlock with Entity Framework. Short version of the problem: In SQL Server, i have 2 tables: table A has a computed primary key and table B has a foreign key referencing that primary key. Problem is that EF doesn't allow modification to tables with computed PK. Futhermore, EF doensn't allow FK referencing candidate keys, Ergo the deadlock Long version of the problem: Say I have 2 tables: TableA( AIdentity int not null identity(1,1), AId as N'A' + right(N'0000' + cast(MSKH as nvarchar(4)), 4) persisted not null primary key ) TableB( AId nvarchar(6) not null foreign key references TableA(AId) ) /Because of display issues, the FK in TableB must reference AId, it cannot reference AIdentity/ When I imported the database into WPF with EF and programatically added values to TableA, the "Modifications...are not supported" error was thrown. Then I changed my logic, converting the database to as follow: TableA( AIdentity int not null identity(1,1) primary key, AId nvarchar(6) unique ) TableB( AId nvarchar(6) not null foreign key references TableA(AId) ) , and added triggers that changed AId appropriately after each insertion. However, EF doesn't support FK referencing candidate keys, ergo the aforementioned deadlock Can anyone help point me towards the right direction because this is ridiculous.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server