mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tree:
bb37541c04
10.0-ai-docs
2024-06-21-Use_User-Defined_Function_Mapping_For_Global_Filter
8.0-prevent-stackoverflow-blazor
9.0-clear-breadcrumbs
BackgroundJob-ApplicationName-Test
Blazorise-Form-Submit
ExtensionPropertyPolicy-Test
IApplicationConfigurationContributor
IGuidGenerator
IReadOnlyAppService
InboxProcessor-OutboxSender
InteractiveServerRenderMode(prerender-true)
Issue-#23338
LockoutEnd-Time
NullAbpDistributedLock-patch
Operation-Rate-Limiting-Test
RandomHelper
Testcontainers
Theme-Async
TimezoneHelpText
X509KeyStorageFlags
abp-plugin
abp-release-post
abp-studio/issue/2891
abp-united-pre-merge
add-loading-component
advanced-features
article/angular-multithreading
auto-merge/prerel-8-2/2729
auto-merge/prerel-9-0/3134
auto-merge/prerel-9-0/3181
auto-merge/rel-0-0/42712
auto-merge/rel-0-0/42712-1
auto-merge/rel-10-0/4007
auto-merge/rel-10-0/4064
auto-merge/rel-10-0/4133
auto-merge/rel-10-1/4237
auto-merge/rel-10-2/4454
auto-merge/rel-10-2/4463
auto-merge/rel-7-4/2239
auto-merge/rel-7-4/2263
auto-merge/rel-7-4/2276
auto-merge/rel-8-0/2472
auto-merge/rel-8-0/2715
auto-merge/rel-8-0/2741
auto-merge/rel-8-1/2527
auto-merge/rel-8-2/2851
auto-merge/rel-8-3/3151
auto-merge/rel-9-0/3296
auto-merge/rel-9-0/3304
auto-merge/rel-9-1/3656
auto-merge/rel-9-2/3571
auto-merge/rel-9-2/3652
aws-service-url
before-net10
blazor-full-stack-web-ui-interactiveauto
blazor-full-stack-web-ui-interactiveauto-modified
clear-breadcrumbs
cmskit-cache
copilot/allow-adding-public-website
copilot/sub-pr-24469
copilot/sub-pr-24636
copilot/sub-pr-24842
copilot/sub-pr-24889
copilot/sub-pr-24949
data-collection-code-review-2
data-collection-review-3
data-collection-review-5
dev
devnot-demo
dgnyldrm7-patch-1
docs-fix
docs-preview-8.3
docs-test-1
docs-unification
docs-unification-1-enhancements
docs/studio-2.2.1
docs/studio-2.2.2
docs/studio-2.2.3
docs/studio-2.2.4
document-abp-run-watch-command
document-index-backgroundjob
documentation/#20827-modular-monolith-application
documentation/20827
documentation/abp-extensible-form-doc
ebicoglu-patch-1
ebicoglu-patch-2
enisn-patch-1
enisn/blobstoring-bunnycdn
feat/#23955
feat/dynamic-form-component
feat/mudblazor
feat/mudblazor-mix
feat/typescript-on-mvc
feature/#19594
feature/#23180
feature/data-collection
feature/logo-provider
feature/ssr-migration-schematic
feature/url-based-localization
fix-admin-docs-test
fix/#20241
fix/#23795
fix/21899-resource-permission-refresh
fullstackblazor
gizem/HTML-encode-TagHelper-xss-test
gizem/security-logs
halil-presentation-2024-05
hybrid-ui
hybrid-ui-embedding
ingress-nginx/ingress-nginx
issue-#23231
issue-#3417
issue-#3591
issue-#3596
issue-#6679
issue-#6768
issue-18421
issue-19307
issue-20436
issue-20924-2
issue-21015
issue-22408
issue-23113
issue-23231
issue-23231-v2
issue-23286
issue-24272
issue-24438-test
issue-24635-test
issue-24672
issue-24674
issue-24918-2
issue-24918-bg-workers
issue-2884
issue-3384/L
issue-3596
issue-3870/L
issue-5131
issue-5384
issue-volo-21285
issue-vs-7809
issue/22675
issue/abp-ng-upgrade
issue/assign-available-port-for-suite
issue/updateAngularInstallers
jquery-form-extensions.js-v2
leptonx-versions
license-banner-localization
license-banner-localization-1
local-ref-basic-theme
maliming-patch-1
maliming-patch-2
maliming-patch-4
maliming/ParameterApiDescriptionModel
maliming/ShouldValidatePredicates
mansur-vs-internal-#7864
mauiglobalbundle
migrating-abp-packages/core
migrating-abp-packages/identity
migrating-abp-packages/setting-management
migrating-abp-packages/tenant-management
migrating-abp-packages/theme-shared
oauth2-redirect.html
pr/2526
pr/6814
prerel-9.0
react-announcement
rel-1.0
rel-1.1
rel-10.0
rel-10.1
rel-10.2
rel-10.3
rel-2.0
rel-2.1
rel-2.2
rel-2.3
rel-2.4
rel-2.5
rel-2.6
rel-2.7
rel-2.8
rel-2.9
rel-3.0
rel-3.1
rel-3.2
rel-3.3
rel-4.0
rel-4.1
rel-4.2
rel-4.3
rel-4.4
rel-5.0
rel-5.1
rel-5.2
rel-5.3
rel-6.0
rel-7.0
rel-7.1
rel-7.2
rel-7.3
rel-7.4
rel-8.0
rel-8.1
rel-8.2
rel-8.3
rel-9.0
rel-9.1
rel-9.2
rel-9.3
remove-deprecateds
return-code-vs-exception-article
revert-18876-blazor-full-stack-web-ui
revert-20264-EngincanV/cli-old-vs-new
revert-23436-Mapperly-maliming
salihozkara-patch-1
salihozkara-patch-2
salihozkara/ImproveBundleFile
salihozkara/blazorise-validation-message
salihozkara/complex-property
salihozkara/fix-image
salihozkara/fixDatePicker
salihozkara/mapperly-test
skoc10-patch-1
skoc10-patch-2
social-login-usages
studio-custom-command-doc
studio-document-start-and-wait
template-config-provider
templates-version
test-branch-24299
test-fix/resource-permission-definition-bugs
update-bundle
update-cli-docs
update-doc
update-latest-versions-7.4.3
update-latest-versions-8.1.2
update-latest-versions-8.1.5
update-latest-versions-8.2.3
update-latest-versions-9.0.7
update-latest-versions-9.1.0
update-upgrade-cod-23-08-2024
upgrade-command-doc
vs-internal-issue-#7727
vs-internal-issue-#8299
vsInternal-viewcChangeHistory-localization
vsinternal-7565
zh-hans.json
ìssue-17361
0.10.0
0.11.0
0.12.0
0.13.0
0.14.0
0.15.0
0.16.0
0.17.0.0
0.18.0
0.18.1
0.19.0
0.20.0
0.20.1
0.21.0
0.22.0
0.3.7
0.4.0
0.4.1
0.4.1.1
0.5.0
0.6.0
0.6.1
0.7.0
0.7.1
0.8.0
0.9.0
1.0.0
1.0.2
1.1.0
1.1.1
1.1.2
10.0.0
10.0.0-rc.1
10.0.0-rc.2
10.0.0-rc.3
10.0.1
10.0.2
10.0.3
10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1
7.1.0-rc.2
7.1.0-rc.3
7.1.1
7.2.0-rc.1
7.2.0-rc.2
7.2.1
7.2.2
7.2.3
7.3.0
7.3.0-rc.1
7.3.0-rc.2
7.3.0-rc.3
7.3.1
7.3.2
7.3.3
7.4.0
7.4.0-rc.1
7.4.0-rc.2
7.4.0-rc.3
7.4.0-rc.4
7.4.0-rc.5
7.4.1
7.4.2
7.4.3
7.4.4
7.4.5
8.0.0
8.0.0-rc.1
8.0.0-rc.2
8.0.0-rc.3
8.0.1
8.0.2
8.0.3
8.0.4
8.0.5
8.0.6
8.1.0
8.1.0-rc.1
8.1.0-rc.2
8.1.0-rc.3
8.1.0-rc.4
8.1.1
8.1.2
8.1.3
8.1.4
8.1.5
8.2.0
8.2.0-rc.1
8.2.0-rc.2
8.2.0-rc.3
8.2.0-rc.4
8.2.0-rc.5
8.2.1
8.2.2
8.2.3
8.3.0
8.3.0-rc.1
8.3.0-rc.2
8.3.0-rc.3
8.3.1
8.3.2
8.3.3
8.3.4
9.0.0
9.0.0-rc.1
9.0.0-rc.2
9.0.0-rc.3
9.0.1
9.0.2
9.0.3
9.0.4
9.0.5
9.0.6
9.0.7
9.0.8
9.1.0
9.1.0-rc.1
9.1.0-rc.2
9.1.0-rc.3
9.1.1
9.1.2
9.1.3
9.2.0
9.2.0-rc.1
9.2.0-rc.2
9.2.0-rc.3
9.2.0-rc.4
9.2.1
9.2.2
9.2.3
9.2.4
9.3.0
9.3.0-rc.1
9.3.0-rc.2
9.3.0-rc.3
9.3.0-rc.4
9.3.1
9.3.2
9.3.3
9.3.4
9.3.5
9.3.6
9.3.7
v0.3.1
v0.3.2
v0.3.2.1
v0.3.2.2
v0.3.3
v0.3.3.1
v0.3.3.2
v0.3.4
v0.3.5
v0.3.6
v0.6.2
v1.1.1
v9.2.0-preview
${ noResults }
2.5 KiB
2.5 KiB
Entity Framework Core 集成
本文介绍了如何将EF Core作为ORM提供程序集成到基于ABP的应用程序以及如何对其进行配置.
安装
Volo.Abp.EntityFrameworkCore 是EF Core 集成的主要nuget包. 将其安装到你的项目中(在分层应用程序中适用于 数据/基础设施层):
Install-Package Volo.Abp.EntityFrameworkCore
然后添加 AbpEntityFrameworkCoreModule 模块依赖项到 module(项目中的Mudole类):
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace MyCompany.MyProject
{
[DependsOn(typeof(AbpEntityFrameworkCoreModule))]
public class MyModule : AbpModule
{
//...
}
}
创建 DbContext
你可以平常一样创建DbContext,它需要继承自 AbpDbContext<T>. 如下所示:
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace MyCompany.MyProject
{
public class MyDbContext : AbpDbContext<MyDbContext>
{
//...your DbSet properties
public MyDbContext(DbContextOptions<MyDbContext> options)
: base(options)
{
}
}
}
将DbContext注册到依赖注入
在module中的ConfigureServices方法使用 AddAbpDbContext 在依赖注入系统注册DbContext类.
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace MyCompany.MyProject
{
[DependsOn(typeof(AbpEntityFrameworkCoreModule))]
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyDbContext>();
//...
}
}
}
添加默认仓储
ABP会自动为DbContext中的实体创建仓储 (TODO: link). 需要在注册的时使用AddDefaultRepositories():
services.AddAbpDbContext<MyDbContext>(options =>
{
options.AddDefaultRepositories();
});
默认情况下为每个聚合根实体(从聚合体派生的类)创建一个仓储. 如果想要为其他实体也创建仓储
需要把includeAllEntities 设置为 true:
services.AddAbpDbContext<MyDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
});
然后你就可以在服务中注入和使用 IRepository<TEntity> 或 IQueryableRepository<TEntity>.
添加自定义仓储
TODO ...
为默认仓储设置Base DbContext类或接口
TODO ...
替换其他仓储
TODO ...