mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-07-30 17:30:40 +00:00
README
This commit is contained in:
@@ -27,6 +27,17 @@ jobs:
|
||||
- name: Build and run unit tests
|
||||
run: dotnet test Tests/Unit/Esiur.Tests.Unit.csproj --configuration Release --no-restore --verbosity minimal
|
||||
|
||||
- name: Build and run CLI tests
|
||||
run: dotnet test Tests/Esiur.CLI.Tests/Esiur.CLI.Tests.csproj --configuration Release --no-restore --verbosity minimal
|
||||
|
||||
- name: Pack and install CLI tool
|
||||
shell: pwsh
|
||||
run: |
|
||||
dotnet pack Tools/Esiur.CLI/Esiur.CLI.csproj --configuration Release --no-build --no-restore --output artifacts/nuget
|
||||
dotnet tool install Esiur.CLI --version 3.0.0 --tool-path artifacts/tool --add-source artifacts/nuget
|
||||
& ./artifacts/tool/esiur.exe version
|
||||
& ./artifacts/tool/esiur.exe --help
|
||||
|
||||
- name: Build standalone web example
|
||||
run: dotnet build Examples/StandaloneWebServer/Esiur.Examples.StandaloneWebServer.csproj --configuration Release --no-restore --verbosity minimal
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageId>Esiur.Stores.EntityCore</PackageId>
|
||||
<Version>3.0.0</Version>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="EntityResource.cs" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# Esiur Entity Framework Core Store
|
||||
|
||||
`Esiur.Stores.EntityCore` integrates Esiur resource materialization and paths
|
||||
with Entity Framework Core 10. Version 3.0 targets .NET 10.
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
dotnet add package Esiur.Stores.EntityCore --version 3.0.0
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 10.0.10
|
||||
```
|
||||
|
||||
Install the package for the database provider used by your application before
|
||||
configuring Esiur.
|
||||
|
||||
## Usage
|
||||
|
||||
Configure the database provider first, then attach an `EntityStore` using
|
||||
`UseEsiur`:
|
||||
|
||||
```csharp
|
||||
using Esiur.Resource;
|
||||
using Esiur.Stores.EntityCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var warehouse = new Warehouse();
|
||||
var store = await warehouse.Put("database", new EntityStore());
|
||||
|
||||
DbContextOptions<AppDbContext>? options = null;
|
||||
options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseSqlite("Data Source=app.db")
|
||||
.UseEsiur(store, () => new AppDbContext(options!))
|
||||
.Options;
|
||||
|
||||
await warehouse.Open();
|
||||
|
||||
await using var db = new AppDbContext(options);
|
||||
await db.Database.EnsureCreatedAsync();
|
||||
var device = await db.Devices.AddResourceAsync(
|
||||
new Device { Name = "sensor-1" });
|
||||
```
|
||||
|
||||
An entity exposed as an Esiur resource can use the source generator:
|
||||
|
||||
```csharp
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Esiur.Resource;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
[Resource]
|
||||
public partial class Device
|
||||
{
|
||||
[Key, Export]
|
||||
int id;
|
||||
|
||||
[Export]
|
||||
string name = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
: DbContext(options)
|
||||
{
|
||||
public DbSet<Device> Devices => Set<Device>();
|
||||
}
|
||||
```
|
||||
|
||||
The `UseEsiur` extension works with any EF Core provider. The Esiur test suite
|
||||
covers SQLite persistence and materialization, plus PostgreSQL and MySQL model
|
||||
creation and SQL translation.
|
||||
@@ -3,13 +3,12 @@
|
||||
<PropertyGroup>
|
||||
<Description>Esiur command-line tool</Description>
|
||||
<Copyright>Ahmed Kh. Zamil</Copyright>
|
||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>3.0.0</Version>
|
||||
<PackageId>Esiur.CLI</PackageId>
|
||||
<Authors>Ahmed Kh. Zamil</Authors>
|
||||
<Company>Esiur Foundation</Company>
|
||||
|
||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||
<PackageProjectUrl>https://www.esiur.com/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/esiur/esiur-dotnet/</RepositoryUrl>
|
||||
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
@@ -19,10 +18,10 @@
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>Esiur.Cli</AssemblyName>
|
||||
<AssemblyName>Esiur.CLI</AssemblyName>
|
||||
<RootNamespace>Esiur.CLI</RootNamespace>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile Condition="'$(RuntimeIdentifier)' != ''">true</PublishSingleFile>
|
||||
<SelfContained Condition="'$(RuntimeIdentifier)' != ''">true</SelfContained>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<PublishAot>false</PublishAot>
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ The project targets .NET 10:
|
||||
```console
|
||||
dotnet build Tools/Esiur.CLI/Esiur.CLI.csproj
|
||||
dotnet pack Tools/Esiur.CLI/Esiur.CLI.csproj -c Release
|
||||
dotnet tool install --global --add-source Tools/Esiur.CLI/nupkg Esiur.Cli
|
||||
dotnet tool install --global --add-source Tools/Esiur.CLI/nupkg Esiur.CLI
|
||||
```
|
||||
|
||||
The project is configured for self-contained, single-file, non-trimmed publishing. Platform release archives and installers are planned for the packaging phase.
|
||||
Runtime-specific publishes are configured as self-contained, single-file, and non-trimmed. The NuGet tool remains framework-dependent and requires .NET 10.
|
||||
|
||||
## Login and profiles
|
||||
|
||||
|
||||
Reference in New Issue
Block a user