✅ EF: Instance of Entity Type cannot be tracked (already being tracked)
I am currently doing a little webapi project (https://github.com/neiomi1/StockExchange (it's messy right now, i know)) but am stumbling into the following error while running it for a while:
The instance of entity type 'Tag' cannot be tracked because another instance with the key value '{Id: 2}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.'
The SimulationService BackgroundService creates news daily at simulation speed but I must be creating the News wrong. The relevant classes should be SimulationService.cs, RandomCompanyNews.cs, News.cs, NewsTag.cs, Tag.cs
Excerpt from SimulationService.cs
The instance of entity type 'Tag' cannot be tracked because another instance with the key value '{Id: 2}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.'
The SimulationService BackgroundService creates news daily at simulation speed but I must be creating the News wrong. The relevant classes should be SimulationService.cs, RandomCompanyNews.cs, News.cs, NewsTag.cs, Tag.cs
Excerpt from SimulationService.cs
GitHub
Contribute to neiomi1/StockExchange development by creating an account on GitHub.