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
Full exceptions details (message and stack trace).
System.InvalidOperationException
HResult=0x80131509
Message=**The entity of 'Testcalss' is sharing the table 'Testcalss' with 'Testcalss.HomeAddress#Address', but there is no entity of this type with the same key value that has been marked as 'Added'.** Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values.
Source=Microsoft.EntityFrameworkCore.Relational
StackTrace:
at Microsoft.EntityFrameworkCore.Update.Internal.ModificationCommandIdentityMap.Validate(Boolean sensitiveLoggingEnabled)
at Microsoft.EntityFrameworkCore.Update.Internal.CommandBatchPreparer.CreateModificationCommands(IReadOnlyList`1 entries, Func`1 generateParameterName)
at Microsoft.EntityFrameworkCore.Update.Internal.CommandBatchPreparer.<BatchCommands>d__8.MoveNext()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(Tuple`2 parameters)
at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func`2 operation)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()
at AIS.SharedKernel.Data.CommonDbContext.SaveChanges() in c:\Source\Repos\AIS\AIS.SharedKernel\Data\CommonDbContext.cs:line 42
at AIS.HR.Data.Services.DatabaseInitializer.SeedTestDatabase(HRContext context) in c:\Source\Repos\AIS\AIS.HR\AIS.HR.Data\Services\DatabaseInitializer.cs:line 94
at AIS.HR.API.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, HRContext hrContext) in c:\Source\Repos\AIS\AIS.HR\AIS.HR.API\Startup.cs:line 95
Steps to reproduce
It is a asp.net core project, when initialize database in Startup class' Configure method with the following code.
@Tarig0 Thanks, it make sense.
At the same time, it feels unnatural. For example, if Address’ parent entity is an Employee, then I have to set the Address of that employee when I create an Employee class. Maybe I need to rethink my model.
An aggregateRoot class
A value object class
OnModelingCreating
Full exceptions details (message and stack trace).
Steps to reproduce
It is a asp.net core project, when initialize database in Startup class' Configure method with the following code.
SaveChanges throw InvalidOperationExcetion.
Further technical details
EF Core version: Microsoft.AspNetCore.All Version="2.0.3"
Database Provider: (localdb)\mssqllocaldb
Operating system: Windows 10
IDE: (Visual Studio 2017 15.5.2)
The text was updated successfully, but these errors were encountered: