Aicrosoft.DataAccess
6.4.0
dotnet add package Aicrosoft.DataAccess --version 6.4.0
NuGet\Install-Package Aicrosoft.DataAccess -Version 6.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aicrosoft.DataAccess" Version="6.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aicrosoft.DataAccess --version 6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aicrosoft.DataAccess, 6.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aicrosoft.DataAccess as a Cake Addin
#addin nuget:?package=Aicrosoft.DataAccess&version=6.4.0
// Install Aicrosoft.DataAccess as a Cake Tool
#tool nuget:?package=Aicrosoft.DataAccess&version=6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Aicrosoft.DataAccess
数据持久化的Domain的GenericRepository框架,可以由不同的ORM框架来实现它。
重要接口
IRepository<TEntity, TKey> 针对DbContext中的某个表的实体的存储操作
- TEntity 传入的实体
- TKey 实体的Key
ICommonRepository
- 无关于实体的仅和DB有关的相关操作
Note
- 连接数是与 DbContext 的实例数量相关的。
How To Use
- Add Entity For Table
public class Phone : Entity<Guid>
{
public string? PhoneNumber { get; set; }
}
public class Employe : Entity<int>
{
public string? Name { get; set; }
public List<Phone>? Phones { get; set; }
}
- First Create XXDbContext for Database
public class SqlServerSampleDbContext : DbContext
{
//可初始化连接串
public SqlServerSampleDbContext(DbContextOptions options) : base(options) { }
public DbSet<Employe>? Employes { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
////它会重重通过DbContextOptions传进来的连接串。
// optionsBuilder.UseSqlServer("MyConnectionString")
}
}
- Migration and update database 不必是在可启动的项目里,只要是在有DbContext的项目中即可。
# Install
dotnet tool install --global dotnet-ef
# update
dotnet tool update --global dotnet-ef
# cd the project dir
cd W:\Aicrosoft\ProjectTemplates\Developing\Console\EFRepositorySample
# use the tools on a specific project || 用Nuget包安装到你想生成的项目里
# 注意:版本必须与DbContext引用的版本一致。
dotnet add package Microsoft.EntityFrameworkCore.Design -v 6.0.24
# Install-Package Microsoft.EntityFrameworkCore.Design -Version 6.0.24
# add migration
dotnet ef migrations add init --context SqlServerSampleDbContext
# Updates the database to the last migration or to a specified migration.
dotnet ef database update --context SqlServerSampleDbContext
- Use by IEFRepository
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Aicrosoft.Extensions (>= 6.4.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Aicrosoft.DataAccess:
Package | Downloads |
---|---|
Aicrosoft.DataAccess.EntityFrameworkCore
Package Description |
|
EFRepositorySample
Extensions of Aicrosoft Ltd. |
GitHub repositories
This package is not used by any popular GitHub repositories.