Skip to content

Commit 25b0b1b

Browse files
dev: EF example with Yandex Cloud (#426)
1 parent cd130b3 commit 25b0b1b

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
ydb-version: [ 'trunk', 'latest' ]
39+
ydb-version: [ 'latest', '25.1' ]
4040
dotnet-version: [ 6.0.x, 7.0.x ]
4141
include:
4242
- dotnet-version: 6.0.x

examples/src/EF_YC/CmdOptions.cs renamed to examples/src/EntityFrameworkCore.Ydb.Yandex.Cloud/CmdOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using CommandLine;
22

3-
namespace EF_YC;
3+
namespace EntityFrameworkCore.Ydb.Yandex.Cloud;
44

55
internal class CmdOptions
66
{
7-
[Option('c', "connectionString", Required = true, HelpText = "Connection string")]
7+
[Option("connectionString", Required = true, HelpText = "Connection string")]
88
public string ConnectionString { get; set; } = null!;
99

1010
[Option("saFilePath", Required = true, HelpText = "Sa Key")]

examples/src/EF_YC/EF_YC.csproj renamed to examples/src/EntityFrameworkCore.Ydb.Yandex.Cloud/EntityFrameworkCore.Ydb.Yandex.Cloud.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<RootNamespace>EntityFrameworkCore.Ydb.Yandex.Cloud</RootNamespace>
89
</PropertyGroup>
910

1011
<ItemGroup>

examples/src/EF_YC/Program.cs renamed to examples/src/EntityFrameworkCore.Ydb.Yandex.Cloud/Program.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using CommandLine;
2-
using EF_YC;
32
using EntityFrameworkCore.Ydb.Extensions;
3+
using EntityFrameworkCore.Ydb.Yandex.Cloud;
44
using Microsoft.EntityFrameworkCore;
55
using Microsoft.Extensions.Logging;
66
using Ydb.Sdk.Yc;
@@ -11,11 +11,10 @@ await Parser.Default.ParseArguments<CmdOptions>(args).WithParsedAsync(async cmd
1111
var saProvider = new ServiceAccountProvider(saFilePath: cmd.SaFilePath, loggerFactory: loggerFactory);
1212

1313
var options = new DbContextOptionsBuilder<AppDbContext>()
14-
.UseYdb(cmd.ConnectionString, builder =>
15-
{
16-
builder.WithCredentialsProvider(saProvider);
17-
builder.WithServerCertificates(YcCerts.GetYcServerCertificates());
18-
})
14+
.UseYdb(cmd.ConnectionString, builder => builder
15+
.WithCredentialsProvider(saProvider)
16+
.WithServerCertificates(YcCerts.GetYcServerCertificates())
17+
)
1918
.Options;
2019

2120
await using var db = new AppDbContext(options);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Entity Framework Core YDB to Yandex Cloud Example
2+
3+
A sample application that defines a model, populates it with data, and then queries a database in Yandex Cloud.
4+
5+
## Running
6+
7+
```dotnet
8+
dotnet run --connectionString "UseTls=true;Host=<host>;Port=2135;Database=<database>" --saFilePath "<path/to/SaKey.json>"
9+
```
10+
11+
Required options:
12+
13+
1. `connectionString` - Connection string in ADO.NET format: `Key1=Value1;Key2=Value2;...`.
14+
2. `saFilePath` - path to the service account key.

examples/src/YdbExamples.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Topic", "Topic\Topic.csproj
1919
EndProject
2020
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EF", "EF\EF.csproj", "{0CE9DF93-1411-4E73-BA88-A66018FAB948}"
2121
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EF_YC", "EF_YC\EF_YC.csproj", "{31A2E7BF-45BB-4C63-9DEC-58DD06491EF1}"
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.Ydb.Yandex.Cloud", "EntityFrameworkCore.Ydb.Yandex.Cloud\EntityFrameworkCore.Ydb.Yandex.Cloud.csproj", "{8F7266C7-75BB-4753-9FB2-BDF4678AF73B}"
2323
EndProject
2424
Global
2525
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -59,10 +59,10 @@ Global
5959
{0CE9DF93-1411-4E73-BA88-A66018FAB948}.Debug|Any CPU.Build.0 = Debug|Any CPU
6060
{0CE9DF93-1411-4E73-BA88-A66018FAB948}.Release|Any CPU.ActiveCfg = Release|Any CPU
6161
{0CE9DF93-1411-4E73-BA88-A66018FAB948}.Release|Any CPU.Build.0 = Release|Any CPU
62-
{31A2E7BF-45BB-4C63-9DEC-58DD06491EF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63-
{31A2E7BF-45BB-4C63-9DEC-58DD06491EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
64-
{31A2E7BF-45BB-4C63-9DEC-58DD06491EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
65-
{31A2E7BF-45BB-4C63-9DEC-58DD06491EF1}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{8F7266C7-75BB-4753-9FB2-BDF4678AF73B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{8F7266C7-75BB-4753-9FB2-BDF4678AF73B}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{8F7266C7-75BB-4753-9FB2-BDF4678AF73B}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{8F7266C7-75BB-4753-9FB2-BDF4678AF73B}.Release|Any CPU.Build.0 = Release|Any CPU
6666
EndGlobalSection
6767
GlobalSection(SolutionProperties) = preSolution
6868
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)