[英]Multitenant configuration in efcore 2.2
I use EF Core 2.2
in a multi tenant application with one database. 我在具有一个数据库的多租户应用程序中使用EF Core 2.2
。 I used the following code: 我使用了以下代码:
modelBuilder.Entity<Blog>().HasQueryFilter(b => b.TenantId == _tenantId);
in OnModelCreating
and it works but I would like to apply it to all of my models that have a tenantId
. 在OnModelCreating
,它可以工作,但我想将它应用于我的所有具有tenantId
模型。 Please tell me if there is a way to implement this strategy. 请告诉我是否有办法实施此策略。
Entity Framework Core 2.0 introduces global query filters that can be applied to entities when model is created. Entity Framework Core 2.0引入了全局查询过滤器,可在创建模型时应用于实体。 It makes it easier to build multi-tenant applications and support soft deleting of entities. 它使构建多租户应用程序和支持软删除实体变得更加容易。 use this link: Global query filters in Entity Framework Core 2.0 使用此链接: Entity Framework Core 2.0中的全局查询过滤器
but you dont need caching in this sample. 但是你不需要在这个示例中进行缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.