Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ internal virtual void OnModelCreatingVersion3(ModelBuilder builder)
b.HasKey(p => p.CredentialId);
b.ToTable("AspNetUserPasskeys");
b.Property(p => p.CredentialId).HasMaxLength(1024); // Defined in WebAuthn spec to be no longer than 1023 bytes
#pragma warning disable EF8001 // Owned JSON entities are obsolete
b.OwnsOne(p => p.Data).ToJson();
#pragma warning restore EF8001 // Owned JSON entities are obsolete
});
}

Expand Down
1 change: 1 addition & 0 deletions src/efcore/.github/ISSUE_TEMPLATE/04_feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 💡 Feature request
description: Suggest an idea for this project.
labels: ["customer-reported"]
type: feature
body:
- type: textarea
id: problem
Expand Down
2 changes: 1 addition & 1 deletion src/efcore/azure-pipelines-internal-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ extends:
templateContext:
sdl:
binskim:
prereleaseVersion: ' '
prereleaseVersion: ''
- job: Helix
timeoutInMinutes: 180
pool:
Expand Down
5 changes: 3 additions & 2 deletions src/efcore/eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
<MicrosoftCodeAnalysisWorkspacesMSBuildVersion>5.0.0</MicrosoftCodeAnalysisWorkspacesMSBuildVersion>
</PropertyGroup>
<PropertyGroup Label="Test dependencies">
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.24423.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MicrosoftCodeAnalysisCSharpTestingVersion>1.1.3-beta1.24352.1</MicrosoftCodeAnalysisCSharpTestingVersion>
<!-- For this prerelease version, see https://github.com/dotnet/roslyn-sdk/issues/1175 -->
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.25564.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MicrosoftCodeAnalysisCSharpTestingVersion>1.1.3-beta1.25564.1</MicrosoftCodeAnalysisCSharpTestingVersion>
<AzureIdentityVersion>1.14.2</AzureIdentityVersion>
<AzureResourceManagerCosmosDBVersion>1.3.2</AzureResourceManagerCosmosDBVersion>
<OpenTelemetryExporterInMemoryVersion>1.12.0</OpenTelemetryExporterInMemoryVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/efcore/eng/common/core-templates/job/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
demands: ImageOverride -equals build.ubuntu.2204.amd64
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore1ESPool-Svc-Internal'), False, 'NetCore1ESPool-Internal')]
image: 1es-azurelinux-3
image: 1es-mariner-2
os: linux
${{ else }}:
pool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parameters:
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
preSteps: []
binlogPath: artifacts/log/Debug/Build.binlog
condition: ''
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
dependsOn: ''
pool: ''
is1ESPipeline: ''
Expand Down Expand Up @@ -41,4 +41,4 @@ jobs:

- template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
parameters:
binLogPath: ${{ parameters.binLogPath }}
binLogPath: ${{ parameters.binLogPath }}
2 changes: 1 addition & 1 deletion src/efcore/eng/common/internal-feed-operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function SetupCredProvider {
$url = 'https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1'

Write-Host "Writing the contents of 'installcredprovider.ps1' locally..."
Invoke-WebRequest $url -OutFile installcredprovider.ps1
Invoke-WebRequest $url -UseBasicParsing -OutFile installcredprovider.ps1

Write-Host 'Installing plugin...'
.\installcredprovider.ps1 -Force
Expand Down
2 changes: 1 addition & 1 deletion src/efcore/eng/common/post-build/nuget-verification.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if ($NuGetExePath) {
Write-Host "Downloading nuget.exe from $nugetExeUrl..."
$ProgressPreference = 'SilentlyContinue'
try {
Invoke-WebRequest $nugetExeUrl -OutFile $downloadedNuGetExe
Invoke-WebRequest $nugetExeUrl -UseBasicParsing -OutFile $downloadedNuGetExe
$ProgressPreference = 'Continue'
} catch {
$ProgressPreference = 'Continue'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ steps:
is1ESPipeline: true

${{ each parameter in parameters }}:
${{ parameter.key }}: ${{ parameter.value }}
${{ parameter.key }}: ${{ parameter.value }}
19 changes: 13 additions & 6 deletions src/efcore/eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function GetDotNetInstallScript([string] $dotnetRoot) {

Retry({
Write-Host "GET $uri"
Invoke-WebRequest $uri -OutFile $installScript
Invoke-WebRequest $uri -UseBasicParsing -OutFile $installScript
})
}

Expand Down Expand Up @@ -510,7 +510,7 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) {
Write-Host "Downloading $packageName $packageVersion"
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
Retry({
Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -OutFile $packagePath
Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -UseBasicParsing -OutFile $packagePath
})

if (!(Test-Path $packagePath)) {
Expand Down Expand Up @@ -556,23 +556,30 @@ function LocateVisualStudio([object]$vsRequirements = $null){
Write-Host "Downloading vswhere $vswhereVersion"
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
Retry({
Invoke-WebRequest "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/vswhere/$vswhereVersion/vswhere.exe" -OutFile $vswhereExe
Invoke-WebRequest "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/vswhere/$vswhereVersion/vswhere.exe" -UseBasicParsing -OutFile $vswhereExe
})
}

if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
if (!$vsRequirements) {
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) {
$vsRequirements = $GlobalJson.tools.vs
} else {
$vsRequirements = $null
}
}

$args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')

if (!$excludePrereleaseVS) {
$args += '-prerelease'
}

if (Get-Member -InputObject $vsRequirements -Name 'version') {
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue)) {
$args += '-version'
$args += $vsRequirements.version
}

if (Get-Member -InputObject $vsRequirements -Name 'components') {
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue)) {
foreach ($component in $vsRequirements.components) {
$args += '-requires'
$args += $component
Expand Down
4 changes: 2 additions & 2 deletions src/efcore/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.100",
"version": "10.0.101",
"allowPrerelease": true,
"rollForward": "latestMajor",
"paths": [
Expand All @@ -10,7 +10,7 @@
"errorMessage": "The required .NET SDK wasn't found. Please run ./restore.sh or .\\restore.cmd to install it."
},
"tools": {
"dotnet": "10.0.100",
"dotnet": "10.0.101",
"runtimes": {
"dotnet": [
"$(MicrosoftNETCorePlatformsVersion)"
Expand Down
36 changes: 35 additions & 1 deletion src/efcore/src/EFCore.Abstractions/DeleteBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,39 @@ public enum DeleteBehavior
/// and examples.
/// </para>
/// </remarks>
ClientNoAction
ClientNoAction,

/// <summary>
/// Sets foreign key values to their default values as appropriate when changes are made to tracked entities and creates
/// a foreign key constraint in the database that sets the foreign key values to their default values when the principal
/// is deleted.
/// </summary>
/// <remarks>
/// <para>
/// Not all databases support SET DEFAULT referential action, and some databases have restrictions
/// on when it can be used. For example, when using SQL Server, columns must have explicit default
/// values defined for SET DEFAULT to work. Consider using <see cref="ClientSetDefault" /> when
/// database restrictions prevent the use of this option.
/// </para>
/// <para>
/// See <see href="https://aka.ms/efcore-docs-cascading">EF Core cascade deletes and deleting orphans</see> for more information
/// and examples.
/// </para>
/// </remarks>
SetDefault,

/// <summary>
/// Sets foreign key values to their sentinel values as appropriate when changes are made to tracked entities,
/// but creates a non-cascading foreign key constraint in the database.
/// </summary>
/// <remarks>
/// <para>
/// Consider using this option when database restrictions prevent the use of <see cref="SetDefault" />.
/// </para>
/// <para>
/// See <see href="https://aka.ms/efcore-docs-cascading">EF Core cascade deletes and deleting orphans</see> for more information
/// and examples.
/// </para>
/// </remarks>
ClientSetDefault
}
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ private static void AssignOnDeleteAction(
foreignKey.DeleteBehavior = DeleteBehavior.SetNull;
break;

case ReferentialAction.SetDefault:
foreignKey.DeleteBehavior = DeleteBehavior.SetDefault;
break;

case ReferentialAction.Restrict:
foreignKey.DeleteBehavior = DeleteBehavior.Restrict;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,26 +427,26 @@ public static string GetDefaultSqlQueryName(this IReadOnlyEntityType entityType)
/// Sets the SQL string used to provide data for the entity type.
/// </summary>
/// <param name="entityType">The entity type.</param>
/// <param name="name">The SQL string to set.</param>
public static void SetSqlQuery(this IMutableEntityType entityType, string? name)
/// <param name="query">The SQL string to set.</param>
public static void SetSqlQuery(this IMutableEntityType entityType, string? query)
=> entityType.SetAnnotation(
RelationalAnnotationNames.SqlQuery,
Check.NullButNotEmpty(name));
Check.NullButNotEmpty(query));

/// <summary>
/// Sets the SQL string used to provide data for the entity type.
/// </summary>
/// <param name="entityType">The entity type.</param>
/// <param name="name">The SQL string to set.</param>
/// <param name="query">The SQL string to set.</param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The configured value.</returns>
public static string? SetSqlQuery(
this IConventionEntityType entityType,
string? name,
string? query,
bool fromDataAnnotation = false)
=> (string?)entityType.SetAnnotation(
RelationalAnnotationNames.SqlQuery,
Check.NullButNotEmpty(name),
Check.NullButNotEmpty(query),
fromDataAnnotation)?.Value;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class RelationalOwnedNavigationBuilderExtensions
/// </remarks>
/// <param name="builder">The builder for the owned navigation being configured.</param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
[Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
public static OwnedNavigationBuilder ToJson(this OwnedNavigationBuilder builder)
=> builder.ToJson(builder.Metadata.GetNavigation(pointsToPrincipal: false)!.Name);

Expand All @@ -36,6 +37,7 @@ public static OwnedNavigationBuilder ToJson(this OwnedNavigationBuilder builder)
/// </remarks>
/// <param name="builder">The builder for the owned navigation being configured.</param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
[Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwnerEntity, TDependentEntity>(
this OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> builder)
where TOwnerEntity : class
Expand All @@ -53,6 +55,7 @@ public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwn
/// <param name="builder">The builder for the owned navigation being configured.</param>
/// <param name="jsonColumnName">JSON column name to use.</param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
[Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwnerEntity, TDependentEntity>(
this OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> builder,
string? jsonColumnName)
Expand All @@ -71,6 +74,7 @@ public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwn
/// <param name="builder">The builder for the owned navigation being configured.</param>
/// <param name="jsonColumnName">JSON column name to use.</param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
[Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
public static OwnedNavigationBuilder ToJson(
this OwnedNavigationBuilder builder,
string? jsonColumnName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ private static void UniquifyColumnNames(
var declaringEntityType = property.DeclaringType as IConventionEntityType;
#pragma warning disable EF1001 // Internal EF Core API usage.
var identifyingMemberInfo = property.GetIdentifyingMemberInfo();
var isInheritedSharedMember = identifyingMemberInfo != null
var isInheritedSharedMember =
type is not IConventionComplexType
&& identifyingMemberInfo != null
&& ((declaringEntityType != null && identifyingMemberInfo.DeclaringType != type.ClrType)
|| (declaringEntityType == null
&& otherProperty.DeclaringType is IConventionComplexType otherDeclaringComplexType
Expand Down Expand Up @@ -279,26 +281,28 @@ private static void UniquifyColumnNames(
continue;
}

var usePrefix = property.DeclaringType != otherProperty.DeclaringType;
if (!usePrefix
var differentTypes = property.DeclaringType != otherProperty.DeclaringType;
if (!differentTypes
|| (!property.DeclaringType.IsStrictlyDerivedFrom(otherProperty.DeclaringType)
&& !otherProperty.DeclaringType.IsStrictlyDerivedFrom(property.DeclaringType))
|| declaringEntityType?.FindRowInternalForeignKeys(storeObject).Any() == true)
{
var newColumnName = TryUniquify(property, columnName, columns, storeObject, usePrefix, maxLength);
var prefix = CreatePrefix(property.DeclaringType, otherProperty.DeclaringType);
var newColumnName = TryUniquify(property, columnName, columns, storeObject, prefix, maxLength);
if (newColumnName != null)
{
columns[newColumnName] = property;
continue;
}
}

if (!usePrefix
if (!differentTypes
|| (!property.DeclaringType.IsStrictlyDerivedFrom(otherProperty.DeclaringType)
&& !otherProperty.DeclaringType.IsStrictlyDerivedFrom(property.DeclaringType))
|| (otherProperty.DeclaringType as IConventionEntityType)?.FindRowInternalForeignKeys(storeObject).Any() == true)
{
var newOtherColumnName = TryUniquify(otherProperty, columnName, columns, storeObject, usePrefix, maxLength);
var prefix = CreatePrefix(otherProperty.DeclaringType, property.DeclaringType);
var newOtherColumnName = TryUniquify(otherProperty, columnName, columns, storeObject, prefix, maxLength);
if (newOtherColumnName != null)
{
columns[columnName] = property;
Expand All @@ -307,30 +311,36 @@ private static void UniquifyColumnNames(
}
}

foreach (var complexProperty in type.GetDeclaredComplexProperties())
foreach (var complexProperty in type.GetComplexProperties())
{
UniquifyColumnNames(complexProperty.ComplexType, columns, storeObject, maxLength);
}

static string CreatePrefix(IReadOnlyTypeBase type, IReadOnlyTypeBase otherType)
{
var prefix = type.ShortName();
return prefix == otherType.ShortName()
&& type is IComplexType complexType
&& otherType is IComplexType othertComplexType
? CreatePrefix(complexType.ComplexProperty.DeclaringType, othertComplexType.ComplexProperty.DeclaringType)
: prefix;
}
}

private static string? TryUniquify(
IConventionProperty property,
string columnName,
Dictionary<string, IConventionProperty> properties,
in StoreObjectIdentifier storeObject,
bool usePrefix,
string? prefix,
int maxLength)
{
if (property.Builder.CanSetColumnName(null)
&& property.Builder.CanSetColumnName(null, storeObject))
{
if (usePrefix)
if (prefix != null)
{
var prefix = property.DeclaringType.ShortName();
if (!columnName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
columnName = prefix + "_" + columnName;
}
columnName = prefix + "_" + columnName;
}

columnName = Uniquifier.Uniquify(columnName, properties, maxLength);
Expand Down
Loading