1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using Microsoft . EntityFrameworkCore . Cosmos . Metadata ;
5
4
using Microsoft . EntityFrameworkCore . Cosmos . Metadata . Internal ;
6
5
7
6
// ReSharper disable once CheckNamespace
@@ -406,11 +405,11 @@ public static EntityTypeBuilder<TEntity> UseETagConcurrency<TEntity>(this Entity
406
405
/// <see langword="null" /> to revert to the default setting.
407
406
/// </param>
408
407
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
409
- public static EntityTypeBuilder AlwaysCreateShadowIdProperty (
408
+ public static EntityTypeBuilder HasShadowId (
410
409
this EntityTypeBuilder entityTypeBuilder ,
411
410
bool ? alwaysCreate = true )
412
411
{
413
- entityTypeBuilder . Metadata . SetAlwaysCreateShadowIdProperty ( alwaysCreate ) ;
412
+ entityTypeBuilder . Metadata . SetHasShadowId ( alwaysCreate ) ;
414
413
415
414
return entityTypeBuilder ;
416
415
}
@@ -430,11 +429,11 @@ public static EntityTypeBuilder AlwaysCreateShadowIdProperty(
430
429
/// <see langword="null" /> to revert to the default setting.
431
430
/// </param>
432
431
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
433
- public static EntityTypeBuilder < TEntity > AlwaysCreateShadowIdProperty < TEntity > (
432
+ public static EntityTypeBuilder < TEntity > HasShadowId < TEntity > (
434
433
this EntityTypeBuilder < TEntity > entityTypeBuilder ,
435
434
bool ? alwaysCreate = true )
436
435
where TEntity : class
437
- => ( EntityTypeBuilder < TEntity > ) AlwaysCreateShadowIdProperty ( ( EntityTypeBuilder ) entityTypeBuilder , alwaysCreate ) ;
436
+ => ( EntityTypeBuilder < TEntity > ) HasShadowId ( ( EntityTypeBuilder ) entityTypeBuilder , alwaysCreate ) ;
438
437
439
438
/// <summary>
440
439
/// Forces model building to always create a "__id" shadow property mapped to the JSON "id". This was the default
@@ -451,17 +450,17 @@ public static EntityTypeBuilder<TEntity> AlwaysCreateShadowIdProperty<TEntity>(
451
450
/// </param>
452
451
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
453
452
/// <returns>The same builder instance if the configuration was applied, <see langword="null" /> otherwise.</returns>
454
- public static IConventionEntityTypeBuilder ? AlwaysCreateShadowIdProperty (
453
+ public static IConventionEntityTypeBuilder ? HasShadowId (
455
454
this IConventionEntityTypeBuilder entityTypeBuilder ,
456
455
bool ? alwaysCreate ,
457
456
bool fromDataAnnotation = false )
458
457
{
459
- if ( ! entityTypeBuilder . CanSetAlwaysCreateShadowIdProperty ( alwaysCreate , fromDataAnnotation ) )
458
+ if ( ! entityTypeBuilder . CanSetShadowId ( alwaysCreate , fromDataAnnotation ) )
460
459
{
461
460
return null ;
462
461
}
463
462
464
- entityTypeBuilder . Metadata . SetAlwaysCreateShadowIdProperty ( alwaysCreate , fromDataAnnotation ) ;
463
+ entityTypeBuilder . Metadata . SetHasShadowId ( alwaysCreate , fromDataAnnotation ) ;
465
464
466
465
return entityTypeBuilder ;
467
466
}
@@ -481,14 +480,14 @@ public static EntityTypeBuilder<TEntity> AlwaysCreateShadowIdProperty<TEntity>(
481
480
/// </param>
482
481
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
483
482
/// <returns><see langword="true" /> if the configuration can be applied.</returns>
484
- public static bool CanSetAlwaysCreateShadowIdProperty (
483
+ public static bool CanSetShadowId (
485
484
this IConventionEntityTypeBuilder entityTypeBuilder ,
486
485
bool ? alwaysCreate ,
487
486
bool fromDataAnnotation = false )
488
487
{
489
488
Check . NotNull ( entityTypeBuilder , nameof ( entityTypeBuilder ) ) ;
490
489
491
- return entityTypeBuilder . CanSetAnnotation ( CosmosAnnotationNames . AlwaysCreateShadowIdProperty , alwaysCreate , fromDataAnnotation ) ;
490
+ return entityTypeBuilder . CanSetAnnotation ( CosmosAnnotationNames . HasShadowId , alwaysCreate , fromDataAnnotation ) ;
492
491
}
493
492
494
493
/// <summary>
@@ -504,16 +503,16 @@ public static bool CanSetAlwaysCreateShadowIdProperty(
504
503
/// <see langword="null" /> to revert to the default setting.
505
504
/// </param>
506
505
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
507
- public static EntityTypeBuilder IncludeDiscriminatorInJsonId (
506
+ public static EntityTypeBuilder HasDiscriminatorInJsonId (
508
507
this EntityTypeBuilder entityTypeBuilder ,
509
508
bool ? includeDiscriminator = true )
510
509
{
511
510
entityTypeBuilder . Metadata . SetDiscriminatorInKey (
512
511
includeDiscriminator == null
513
512
? null
514
513
: includeDiscriminator . Value
515
- ? DiscriminatorInKeyBehavior . EntityTypeName
516
- : DiscriminatorInKeyBehavior . None ) ;
514
+ ? IdDiscriminatorMode . EntityType
515
+ : IdDiscriminatorMode . None ) ;
517
516
518
517
return entityTypeBuilder ;
519
518
}
@@ -540,8 +539,8 @@ public static EntityTypeBuilder IncludeRootDiscriminatorInJsonId(
540
539
includeDiscriminator == null
541
540
? null
542
541
: includeDiscriminator . Value
543
- ? DiscriminatorInKeyBehavior . RootEntityTypeName
544
- : DiscriminatorInKeyBehavior . None ) ;
542
+ ? IdDiscriminatorMode . RootEntityType
543
+ : IdDiscriminatorMode . None ) ;
545
544
546
545
return entityTypeBuilder ;
547
546
}
@@ -559,10 +558,10 @@ public static EntityTypeBuilder IncludeRootDiscriminatorInJsonId(
559
558
/// <see langword="null" /> to revert to the default setting.
560
559
/// </param>
561
560
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
562
- public static EntityTypeBuilder < TEntity > IncludeDiscriminatorInJsonId < TEntity > (
561
+ public static EntityTypeBuilder < TEntity > HasDiscriminatorInJsonId < TEntity > (
563
562
this EntityTypeBuilder < TEntity > entityTypeBuilder , bool ? includeDiscriminator = true )
564
563
where TEntity : class
565
- => ( EntityTypeBuilder < TEntity > ) IncludeDiscriminatorInJsonId ( ( EntityTypeBuilder ) entityTypeBuilder , includeDiscriminator ) ;
564
+ => ( EntityTypeBuilder < TEntity > ) HasDiscriminatorInJsonId ( ( EntityTypeBuilder ) entityTypeBuilder , includeDiscriminator ) ;
566
565
567
566
/// <summary>
568
567
/// Includes the discriminator value of the root entity type in the JSON "id" value. This allows types with the same
@@ -597,10 +596,10 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
597
596
/// </param>
598
597
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
599
598
/// <returns>The same builder instance if the configuration was applied, <see langword="null" /> otherwise.</returns>
600
- public static IConventionEntityTypeBuilder ? IncludeDiscriminatorInJsonId (
599
+ public static IConventionEntityTypeBuilder ? HasDiscriminatorInJsonId (
601
600
this IConventionEntityTypeBuilder entityTypeBuilder , bool ? includeDiscriminator , bool fromDataAnnotation = false )
602
601
{
603
- if ( ! entityTypeBuilder . CanSetIncludeDiscriminatorInJsonId ( includeDiscriminator , fromDataAnnotation ) )
602
+ if ( ! entityTypeBuilder . CanSetDiscriminatorInJsonId ( includeDiscriminator , fromDataAnnotation ) )
604
603
{
605
604
return null ;
606
605
}
@@ -609,8 +608,8 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
609
608
includeDiscriminator == null
610
609
? null
611
610
: includeDiscriminator . Value
612
- ? DiscriminatorInKeyBehavior . EntityTypeName
613
- : DiscriminatorInKeyBehavior . None , fromDataAnnotation ) ;
611
+ ? IdDiscriminatorMode . EntityType
612
+ : IdDiscriminatorMode . None , fromDataAnnotation ) ;
614
613
615
614
return entityTypeBuilder ;
616
615
}
@@ -642,8 +641,8 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
642
641
includeDiscriminator == null
643
642
? null
644
643
: includeDiscriminator . Value
645
- ? DiscriminatorInKeyBehavior . EntityTypeName
646
- : DiscriminatorInKeyBehavior . None , fromDataAnnotation ) ;
644
+ ? IdDiscriminatorMode . EntityType
645
+ : IdDiscriminatorMode . None , fromDataAnnotation ) ;
647
646
648
647
return entityTypeBuilder ;
649
648
}
@@ -663,7 +662,7 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
663
662
/// </param>
664
663
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
665
664
/// <returns><see langword="true" /> if the configuration can be applied.</returns>
666
- public static bool CanSetIncludeDiscriminatorInJsonId (
665
+ public static bool CanSetDiscriminatorInJsonId (
667
666
this IConventionEntityTypeBuilder entityTypeBuilder ,
668
667
bool ? includeDiscriminator ,
669
668
bool fromDataAnnotation = false )
@@ -675,8 +674,8 @@ public static bool CanSetIncludeDiscriminatorInJsonId(
675
674
includeDiscriminator == null
676
675
? null
677
676
: includeDiscriminator . Value
678
- ? DiscriminatorInKeyBehavior . EntityTypeName
679
- : DiscriminatorInKeyBehavior . None , fromDataAnnotation ) ;
677
+ ? IdDiscriminatorMode . EntityType
678
+ : IdDiscriminatorMode . None , fromDataAnnotation ) ;
680
679
}
681
680
682
681
@@ -707,8 +706,8 @@ public static bool CanSetIncludeRootDiscriminatorInJsonId(
707
706
includeDiscriminator == null
708
707
? null
709
708
: includeDiscriminator . Value
710
- ? DiscriminatorInKeyBehavior . RootEntityTypeName
711
- : DiscriminatorInKeyBehavior . None , fromDataAnnotation ) ;
709
+ ? IdDiscriminatorMode . RootEntityType
710
+ : IdDiscriminatorMode . None , fromDataAnnotation ) ;
712
711
}
713
712
714
713
/// <summary>
0 commit comments