Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

357
Vistas
What is the equivalent of entityEntry.Metadata.DefiningNavigationName() in EF Core 6?

I am using EF Core 5 and I have the following in my DBContext SaveChanges():

            if (entityEntry.Metadata.Name == "ArticleBankAggregate.ArticleTag" && entityEntry.Metadata.DefiningNavigationName != "Tags")
            {
                entityEntry.Property("UpdatedDate").CurrentValue = DateTime.Now;

                if (entityEntry.State == EntityState.Added)

                {
                    entityEntry.Property("CreatedDate").CurrentValue = DateTime.Now;
                }
            }

To update a shadow property.

I am trying to upgrade to EF Core 6 and I get the following:

CS0618: 'IReadOnlyEntityType.DefiningNavigationName' is obsolete: 'Entity types with defining navigations have been replaced by shared-type entity types'

I cant find any examples or understand how to change this to use shared-type entities.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Shared entity types are entity types which use common CLR type (class), and are identified by the entity type name (since the type is not enough).

Owned entity types now are implemented as shared types. The name of owned entity type consists of the name of the owner type + navigation property + type name. e.g. something like {Namespace}.{OwnerType}.{Navigation}#{OwnedType}.

So one way to adjust the above code is check the name of the entity in interest and just test directly for it. Another way closer to what are you doing before is to check the CLR type and in case it is owned, the navigation property name from owner to owned (the equivalent of the "defining navigation name"), which can be obtained with FindOwnership().PrincipalToDependent.Name, e.g. something like

if (entityEntry.Metadata.ClrType == typeof(ArticleTag)
    && entityEntry.Metadata.FindOwnership()?.PrincipalToDependent?.Name != "Tags")
 
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda