简体   繁体   中英

Ef Core Reconciler Not Accepting Null Child Entity

I have been using this Reconciler plugin in my dotnet core web application.

It is similar to GraphDiff but this plugin supports ef core.

I have these lines when I'm updating my model.

_context.Reconcile(applicationForm, r => r.WithMany(m => m.AccessArea).WithMany(m => m.TrainingRecord));
await _context.SaveChangesAsync();

The problem is, Reconcile() doesn't accept null parameter, so when I pass null child entity it hits error.

AggregateException: One or more errors occurred. (Value cannot be null. Parameter name: source)

Any workaround for this?

Much appreciated!

I manage to resolve this by making them an empty list instead of null.

Cheers!

if (applicationForm.AccessArea == null)
{
    applicationForm.AccessArea = new List<AccessAreaCheckBox>();
}
if (applicationForm.TrainingRecord == null)
{
    applicationForm.TrainingRecord = new List<FilePath>();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM