基于复合键插入重复项的实体框架

我试图将一个大的对象列表插入到我的数据库中(一次大约30000条记录),并根据不同列的组合键判断记录是否是重复的行。下面的代码可以让这更清楚一点:

await {db_context}.AddRangeAsync(Metrics.Where(x =>!MetricsInDb.AsEnumerable().Any(y => 
x.CreativeId == y.CreativeId 
&& x.LineItemId == y.LineItemId 
&& x.Date.Date == y.Date.Date 
&& x.City == y.City 
&& x.Country == y.Country 
&& x.Metro == y.Metro 
&& x.State == y.State)));

为了进一步解释,我有两个清单。

Metrics is a List of objects I'm inserting.
MetricsInDb is another List of objects I'm comparing against.
in the .Any(), essentially I'm trying to say, if ALL of these columns are matching, then it's a duplicate. Do not insert that duplicate row.

在我看来,逻辑似乎是合理的。我不确定是否有更好的方法在这样一个大的复合键上这样做。

I originally had a .AsParallel() here.... Metrics.AsParallel().Where(x => !MetricsInDb.......) which I removed thinking that was the issue, it's obviously not after a few runs it's still inserting duplicates.

任何和所有的提示都会非常有用。提前谢谢!