You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EF Core version: 7.0.9
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: IDE: Windows - Visual Code
I'm getting the following exception:
Exception has occurred: CLR/System.InvalidOperationException
An exception of type 'System.InvalidOperationException' occurred in NCPC.Infra.dll but was not handled in user code: 'The value of shadow key property 'InformacaoCoordenada.Id' is unknown when attempting to save changes. This is because shadow property values cannot be preserved when the entity is not being tracked. Consider adding the property to the entity's .NET type. See https://aka.ms/efcore-docs-owned-collections for more information.'
at NCPC.Infra.UnitOfWork.SaveChanges() in C:\Projetos\NCPC\NCPC.Infra\UnitOfWork.cs:line 123
at CapturaXML.Test.UnitTest1.ShouldUpdateTipoCobranca() in c:\Projetos\NC\CapturaXML\CapturaXML.Test\UnitTest1.cs:line 114
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
The case is that I have an entity with a Json Column mapped
When I try to update the Entity (without tracking) it throws the error
[Fact]
public void ShouldUpdateTipoCobranca()
{
var context = new ContextProvider();
var uow = context.ServiceProvider.GetRequiredService<IUnitOfWork>();
var mapper = context.ServiceProvider.GetRequiredService<IMapper>();
var tipoCobrancaRepo = uow.GetRepository<TipoCobrancaRepository>();
var tipoCobranca = tipoCobrancaRepo.GetAll().AsNoTracking().First();
var viewModel = mapper.Map<TipoCobrancaViewModel>(tipoCobranca);
tipoCobranca = mapper.Map<TipoCobranca>(viewModel);
tipoCobrancaRepo.Attatch(tipoCobranca);
tipoCobranca.Identificadores.First().Width+=1;
tipoCobrancaRepo.Update(tipoCobranca);
uow.SaveChanges();
Assert.NotNull(tipoCobranca);
}
I've already tried to create a Key Property but I get another error
Any thoughts?
The text was updated successfully, but these errors were encountered:
Note for triage: is there any way to currently achieve this when the owned collection is mapped to JSON? The normal guidance is to explicitly declare the key, but I think that is blocked when using JSON mapping.
EF Core version: 7.0.9
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: IDE: Windows - Visual Code
I'm getting the following exception:
Exception has occurred: CLR/System.InvalidOperationException
An exception of type 'System.InvalidOperationException' occurred in NCPC.Infra.dll but was not handled in user code: 'The value of shadow key property 'InformacaoCoordenada.Id' is unknown when attempting to save changes. This is because shadow property values cannot be preserved when the entity is not being tracked. Consider adding the property to the entity's .NET type. See https://aka.ms/efcore-docs-owned-collections for more information.'
at NCPC.Infra.UnitOfWork.SaveChanges() in C:\Projetos\NCPC\NCPC.Infra\UnitOfWork.cs:line 123
at CapturaXML.Test.UnitTest1.ShouldUpdateTipoCobranca() in c:\Projetos\NC\CapturaXML\CapturaXML.Test\UnitTest1.cs:line 114
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
The case is that I have an entity with a Json Column mapped
When I try to update the Entity (without tracking) it throws the error
I'm mapping the column with :
and I have written the following test:
I've already tried to create a Key Property but I get another error
Any thoughts?
The text was updated successfully, but these errors were encountered: