Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="fakeiisexpress.fs" />
Expand Down
8 changes: 5 additions & 3 deletions src/SqlClient.DesignTime/SqlClientProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ type SqlProgrammabilityProvider(config : TypeProviderConfig) as this =
?defaultValue = x.TryGetValue("default_constraint"),
?description = x.TryGetValue("description")
)
if c.DefaultConstraint <> "" && c.PartOfUniqueKey
if c.DefaultConstraint <> "" && c.Nullable && c.PartOfUniqueKey
then
{ c with PartOfUniqueKey = false }
//ADO.NET doesn't allow nullable columns as part of primary key
//remove from PK if default value provided by DB on insert.
//ADO.NET doesn't allow null values in primary key columns.
//Only remove nullable columns from PK when they have a default value,
//since nullable+default columns may be omitted in NewRow() and remain null.
//Non-nullable columns with defaults should stay in PK - callers must supply them.
else c
)
|> Seq.toList
Expand Down
Loading