Open
Description
Background and motivation
When a duplicate key value interrupts a SQL command, you get a SqlException with a message like this:
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.__M_Matters' with unique index 'IX___M_Matters_Id'. The duplicate key value is (SB2 --- Accounts Payable).
It would be really nice if the duplicate key value was available as a property.
API Proposal
namespace Microsoft.Data.SqlClient;
public class DuplicateKeyException : SqlException
{
public string Key {get; set;}
}
API Usage
It is a new exception that would be thrown.
Alternative Designs
No response
Risks
No response