I have the following class derived from entity framework class as follows.
internal class MyInitializer : CreateDatabaseIfNotExists<ConfigurationDbContext>
{
protected override async void Seed(ConfigurationDbContext context)
{
await DbHelper.AddSampleDataAsync(context);
base.Seed(context);
}
}
I get the following compiler error when I change "void" to "async Task".
return type must be 'void' to match overridden member
async/await best practices tell you to almost always return async Task instead of void. Just wanted to make sure my usage of void here is one of those acceptable scenarios for using void. What other options do I have anyways?
Seed(either through this type or through the parent type) going to function properly if it returns before the work is actually done, and without providing any means of determining the result (or any errors) of this operation? If yes, leave the async void method, if no, you have to either not do the operation asynchronously, or not meet this signature. - Servy