HamidMosalla / FreelancerBlog

FreelancerBlog is a blog built with Asp.Net Core around the idea of hexagonal architecture and CQRS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ContextSeedData not working

arianshahalami opened this issue · comments

Hi there, there is a problem with FreelanceBlogContextSeedData.cs. When I launch the code, I get this error in that class :
System.ObjectDisposedException: 'Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'FreelancerBlogContext'.'

HERE IS A RELATED IMAGE
Untitled

You should add .Wait() to SeedAdminUser method in Startup->Configure and change return type of SeedAdminUser method from void to Task.
seeder.SeedAdminUser().Wait();

The issue is fixed now.