AddOrUpdateAsync in SampleData.cs implies that you can run it even if the data exists already. However, it would seem that EntityFramework does not support the following call and will throw an exception if the data exists:
The instance of entity type 'MusicStore.Models.Genre' cannot be tracked because another instance of this type with the same key is already being tracked. For new entities consider using an IIdentityGenerator to generate unique key values.
AddOrUpdateAsync however is only ever called if the database is being created, due to EnsureCreatedAsynchere.
AddOrUpdateAsync
in SampleData.cs implies that you can run it even if the data exists already. However, it would seem that EntityFramework does not support the following call and will throw an exception if the data exists:Exception
AddOrUpdateAsync
however is only ever called if the database is being created, due toEnsureCreatedAsync
here.