Search code examples
sqllinqlinq-to-sqllinqpad

Why is Linq/Linqpad not recognising primary key of table after a primary key was added to it?


I've got a little script in Linqpad to update some tables in an old DB, some of these tables did not have primary keys set. After updating those tables and amending a column to be a primary key INT non-nullable field and marking it as the identity column Linqpad is still telling me it can't create/update/delete on that table as it has no primary key. Is there something else I need to do before Linqpad will acknoweldge these tables now have a primary key?


Solution

  • Nevermind, I realised my problem. In Linqpad I had constructed a connection based on two databases that the script was running in. I had been refreshing the original database connection for the database I had been updating. Simply refreshing the created combined connection in Linqpad resolved the issue.