Многочисленные ошибки проверки с использованием HasQueryFilter().C#

Место общения программистов C#
Ответить
Anonymous
 Многочисленные ошибки проверки с использованием HasQueryFilter().

Сообщение Anonymous »

Я пытаюсь реализовать обратимое удаление, используя методы, описанные в этом видео и этой статье.
Я добавил в свою сущность два столбца.

Код: Выделить всё

public bool IsDeleted { get; set; }
public DateTime? DeletedOnUtc { get; set; }
И я добавил следующее в свой OnModelCreating.

Код: Выделить всё

builder.Entity().HasQueryFilter(c => c.IsDeleted == false);

builder.Entity()
.HasIndex(c => c.IsDeleted)
.HasFilter("IsDeleted = 0");
Но когда я добавляю миграцию с использованием этих изменений, я получаю множество предупреждений проверки, касающихся связанных таблиц.

Код: Выделить всё

Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'CompanyReport'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Customer'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Image'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'PdfTemplate'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Product'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ProductCategory'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ReportJob'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'CompanyReport'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'CompanyReport'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Customer'. This may lead to unexpected results when the required entity is filtered out.  Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Customer'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Image'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Image'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'PdfTemplate'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'PdfTemplate'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Product'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'Product'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Microsoft.EntityFrameworkCore.Model.Validation[10622]
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ProductCategory'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ProductCategory'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ReportJob'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Entity 'Company' has a global query filter defined and is the required end of a relationship with the entity 'ReportJob'. This may lead to unexpected results when the required entity is filtered out. Either configure the navigation as optional, or define matching query filters for both entities in the navigation. See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.
Ссылку прочитал, но не понятно, зачем мне этим заниматься, а в упомянутых мною статьях нет. Действительно ли мне нужно изменить каждый из существующих внешних ключей?
Кто-то, кто лучше это понимает, объяснит, что я делаю неправильно?

Подробнее здесь: https://stackoverflow.com/questions/790 ... ueryfilter
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»