Librame.Extensions.Data.EntityFrameworkCore
7.0.898.201
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Librame.Extensions.Data.EntityFrameworkCore --version 7.0.898.201
NuGet\Install-Package Librame.Extensions.Data.EntityFrameworkCore -Version 7.0.898.201
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="Librame.Extensions.Data.EntityFrameworkCore" Version="7.0.898.201" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Librame.Extensions.Data.EntityFrameworkCore --version 7.0.898.201
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Librame.Extensions.Data.EntityFrameworkCore, 7.0.898.201"
#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 Librame.Extensions.Data.EntityFrameworkCore as a Cake Addin
#addin nuget:?package=Librame.Extensions.Data.EntityFrameworkCore&version=7.0.898.201
// Install Librame.Extensions.Data.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=Librame.Extensions.Data.EntityFrameworkCore&version=7.0.898.201
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Librame.Extensions.Data.EntityFrameworkCore
Install Extension
PM> Install-Package Librame.Extensions.Data.EntityFrameworkCore
Register Extension
services.AddLibrame()
.AddData(options =>
{
// Multi-Tenancy, Reading and writing separation
options.DefaultTenant.DefaultConnectionString = "default database connection string";
options.DefaultTenant.WritingConnectionString = "write database connection string";
options.DefaultTenant.WritingSeparation = true;
})
.AddAccessor<TestDbContextAccessor>((options, optionsBuilder) =>
{
// Install-Package Microsoft.EntityFrameworkCore.SqlServer
optionsBuilder.UseSqlServer(options.DefaultTenant.DefaultConnectionString,
sql => sql.MigrationsAssembly("AssemblyName"));
})
.AddStoreHubWithAccessor<TestStoreHub>()
.AddInitializerWithAccessor<TestStoreInitializer>()
.AddIdentifier<TestStoreIdentifier>()
.AddDbDesignTime<SqlServerDesignTimeServices>();
Test Extension
// StoreHub
public class TestStoreHub : StoreHubBase<TestDbContextAccessor>
{
public TestStore(IAccessor accessor, IStoreInitializer<TestDbContextAccessor> initializer)
: base(accessor, initializer)
{
}
public IList<Category> GetCategories()
{
return Accessor.Categories.ToList();
}
public IPageable<Article> GetArticles()
{
return Accessor.Articles.AsDescendingPagingByIndex(1, 10);
}
public TestStoreHub UseWriteDbConnection()
{
Accessor.TryChangeDbConnection(t => t.WritingConnectionString);
return this;
}
public TestStoreHub UseDefaultDbConnection()
{
Accessor.TryChangeDbConnection(t => t.DefaultConnectionString);
return this;
}
}
// DbContextAccessor
public class TestDbContextAccessor : DbContextAccessor
{
public TestDbContextAccessor(DbContextOptions options)
: base(options)
{
}
public DbSet<Category> Categories { get; set; }
public DbSet<Article> Articles { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
......
}
}
// Test
using (var stores = serviceProvider.GetRequiredService<TestStoreHub>())
{
var categories = stores.GetCategories();
Assert.Empty(categories);
categories = stores.UseWriteDbConnection().GetCategories();
Assert.NotEmpty(categories);
var articles = stores.UseDefaultDbConnection().GetArticles();
Assert.Empty(articles);
articles = stores.UseWriteDbConnection().GetArticles();
Assert.True(articles.Total >= 0); // If enable sharding table, the articles of this table may be empty
}
......
// Librame.Extensions.Data.Tests.DbContextAccessorTests
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Librame.Extensions.Core (>= 7.0.898.201)
- Librame.Extensions.Data.Abstractions (>= 7.0.898.201)
- Microsoft.CodeAnalysis.Common (>= 3.3.1)
- Microsoft.CodeAnalysis.CSharp (>= 3.3.1)
- Microsoft.EntityFrameworkCore.Design (>= 3.0.0)
- Microsoft.Extensions.DependencyModel (>= 3.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Librame.Extensions.Data.EntityFrameworkCore:
Package | Downloads |
---|---|
Librame.AspNetCore.Data.EntityFrameworkCore
Based Librame.AspNetCore.Data.Abstractions and EntityFrameworkCore on ASP.NET Core extension implementation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Based Librame.Extensions.Data.Abstractions on EntityFrameworkCore extension implementation.