Skip to content

Commit 255241c

Browse files
testing examples
1 parent c93f637 commit 255241c

File tree

15 files changed

+230
-13
lines changed

15 files changed

+230
-13
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
info: AppContext[0]
2+
Start app example
3+
info: AppContext[0]
4+
Created tables
5+
info: AppContext[0]
6+
Loaded data
7+
info: AppContext[0]
8+
Selected rows:
9+
info: AppContext[0]
10+
series_id: 1, season_id: 2, episode_id: 1, air_date: 08/24/2006 00:00:00, title: The Work Outing
11+
info: AppContext[0]
12+
series_id: 1, season_id: 2, episode_id: 2, air_date: 08/31/2007 00:00:00, title: Return of the Golden Child
13+
info: AppContext[0]
14+
series_id: 1, season_id: 2, episode_id: 3, air_date: 09/07/2007 00:00:00, title: Moss and the German
15+
info: AppContext[0]
16+
series_id: 1, season_id: 1, cnt: 6
17+
info: AppContext[0]
18+
series_id: 1, season_id: 2, cnt: 6
19+
info: AppContext[0]
20+
series_id: 1, season_id: 3, cnt: 6
21+
info: AppContext[0]
22+
series_id: 1, season_id: 4, cnt: 6
23+
info: AppContext[0]
24+
series_id: 2, season_id: 1, cnt: 8
25+
info: AppContext[0]
26+
series_id: 2, season_id: 2, cnt: 10
27+
info: AppContext[0]
28+
series_id: 2, season_id: 3, cnt: 10
29+
info: AppContext[0]
30+
series_id: 2, season_id: 4, cnt: 10
31+
info: AppContext[0]
32+
series_id: 2, season_id: 5, cnt: 8
33+
info: AppContext[0]
34+
Creating user with password: [user, password]
35+
info: AppContext[0]
36+
Created user
37+
info: AppContext[0]
38+
Clearing all pools...
39+
info: AppContext[0]
40+
Cleared all pools
41+
info: AppContext[0]
42+
Commit transaction
43+
info: AppContext[0]
44+
New episode title: Test 21
45+
info: AppContext[0]
46+
New episode title: Test 22
47+
info: AppContext[0]
48+
New episode title: Test 21
49+
info: AppContext[0]
50+
Updated episode title: Test Episode
51+
info: AppContext[0]
52+
Tls example was ignored
53+
info: AppContext[0]
54+
Iterate by resultSets: 2
55+
info: AppContext[0]
56+
Iterate by resultSets: 3
57+
info: Ydb.Sdk.Driver[0]
58+
Started initial endpoint discovery
59+
info: AppContext[0]
60+
Dropping tables of examples
61+
info: AppContext[0]
62+
Dropped tables of examples
63+
info: AppContext[0]
64+
Finish app example

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ jobs:
185185
- name: Run ADO.NET example
186186
run: |
187187
docker cp ydb-local:/ydb_certs/ca.pem ~/
188-
cd ./examples/src/AdoNet
189-
dotnet run
188+
cd ./examples/Ydb.Sdk.AdoNet.QuickStart
189+
dotnet run >> ad
190190
- name: Run Dapper example
191191
run: |
192192
cd ./examples/src/DapperExample
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Entity Framework Core YDB Quick Start
22

3-
A sample application from the [official documentation](https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli)
3+
A sample application from
4+
the [official documentation](https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli)
45
shows how to get started with EF, define a model, populate it with data and then query the database.
56

67
## Running QuickStart
78

89
1. Setup [YDB local](https://ydb.tech/docs/en/reference/docker/start).
10+
911
2. Create the database:
1012
```bash
1113
dotnet tool install --global dotnet-ef
1214
dotnet add package Microsoft.EntityFrameworkCore.Design
1315
dotnet ef migrations add InitialCreate
1416
dotnet ef database update
1517
```
18+
1619
3. Run the app: `dotnet run`

examples/EntityFrameworkCore.Ydb.Samples/AddEntity.Sample/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
using Section_1.HR;
44

5-
await new HRContext().Database.EnsureDeletedAsync();
6-
75
InsertDepartments();
86
SelectDepartments();
97

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Entity Framework Core YDB Add Entity Sample
2+
3+
This sample introduces the basics of using EF Core with YDB.
4+
It covers what EF Core is, how to create a simple .NET app with EF Core, how to define a data model, set up a database connection, and perform basic CRUD operations via the EF Core API.
5+
6+
Based on the [tutorial](https://www.csharptutorial.net/entity-framework-core-tutorial/getting-started-with-entity-framework-core/).
7+
8+
## Running QuickStart
9+
10+
1. Set up [YDB local](https://ydb.tech/docs/en/reference/docker/start).
11+
12+
2. Install the EF Core CLI tool and dependencies (if needed):
13+
```bash
14+
dotnet tool install --global dotnet-ef
15+
dotnet add package Microsoft.EntityFrameworkCore.Design
16+
```
17+
18+
3. Create the database and apply migrations:
19+
```bash
20+
dotnet ef migrations add InitialCreate
21+
dotnet ef database update
22+
```
23+
24+
4. Run the sample:
25+
```bash
26+
dotnet run
27+
```

examples/EntityFrameworkCore.Ydb.Samples/Database.Operations.Tutorial/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,4 @@ internal enum Action
537537
Like,
538538
InnerJoin,
539539
GroupBy
540-
}
540+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Querying data using LINQ from Entity Framework Core YDB
2+
3+
This sample demonstrates how to query data from YDB using Entity Framework Core and LINQ.
4+
5+
Based on the [tutorial](https://www.csharptutorial.net/entity-framework-core-tutorial/).
6+
7+
## Running
8+
9+
Run all operations sequentially with:
10+
11+
```bash
12+
dotnet run
13+
```
14+
15+
## Available Operations
16+
17+
You can execute individual operations by specifying the desired action as a command-line argument. Available actions:
18+
19+
- ReadCsv
20+
- Select
21+
- OrderBy
22+
- QueryLinq
23+
- Where
24+
- InOperator
25+
- Like
26+
- InnerJoin
27+
- GroupBy
28+
29+
```bash
30+
dotnet run Select
31+
```
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Entity Framework Core Ydb Samples
22

3-
This folder contains sample projects that demonstrating Entity Framework Core YDB.
3+
This project contains a number of samples for using Entity Framework Core in combination with YDB.
44

5-
This guide using [EF Tutorial](https://www.csharptutorial.net/entity-framework-core-tutorial/)
5+
Some samples are inspired by the [Entity Framework Core Tutorial](https://www.csharptutorial.net/entity-framework-core-tutorial).
66

7-
## Running QuickStart
7+
## Samples
88

9-
1. Setup [YDB local](https://ydb.tech/docs/en/reference/docker/start).
10-
2.
9+
- **AddEntity.Sample** – Example for adding entities.
10+
- **Database.Operations.Tutorial** – Basic database operations.
11+
- **Schema.OneToOne** – One-to-one relationship.
12+
- **Schema.OneToMany** – One-to-many relationship.
13+
- **Schema.ManyToMany** – Many-to-many relationship.
14+
15+
## Usage
16+
17+
Each subfolder contains an independent sample.
18+
Please refer to the README or documentation inside each sample folder for instructions on how to run it.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Entity Framework Core YDB Schema Many-to-Many Example
2+
3+
This sample demonstrates how to model a [many-to-many relationship](https://www.csharptutorial.net/entity-framework-core-tutorial/ef-core-many-to-many-relationships/) in Entity Framework Core targeting YDB.
4+
5+
The focus here is to show what database schema (DDL) will be generated by EF Core migrations for such a model.
6+
7+
## How to View the Generated Schema
8+
9+
1. Set up a local YDB instance:
10+
[YDB local setup guide](https://ydb.tech/docs/en/reference/docker/start)
11+
12+
2. Install the EF Core CLI tool (if needed):
13+
```bash
14+
dotnet tool install --global dotnet-ef
15+
dotnet add package Microsoft.EntityFrameworkCore.Design
16+
```
17+
18+
3. Add a migration to generate the DDL (if not already present):
19+
```bash
20+
dotnet ef migrations add InitialCreate
21+
```
22+
23+
4. Generate the SQL script for the schema:
24+
```bash
25+
dotnet ef migrations script
26+
```
27+
28+
5. Inspect the generated SQL script to see how EF Core maps the many-to-many relationship in YDB.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Entity Framework Core YDB Schema One-to-Many Example
2+
3+
This sample demonstrates how to model a [one-to-many relationship](https://www.csharptutorial.net/entity-framework-core-tutorial/ef-core-one-to-many-relationship/) in Entity Framework Core targeting YDB.
4+
5+
The focus here is to show what database schema (DDL) will be generated by EF Core migrations for such a model.
6+
7+
## How to View the Generated Schema
8+
9+
1. Set up [YDB local](https://ydb.tech/docs/en/reference/docker/start).
10+
11+
2. Install the EF Core CLI tool (if needed):
12+
```bash
13+
dotnet tool install --global dotnet-ef
14+
dotnet add package Microsoft.EntityFrameworkCore.Design
15+
```
16+
17+
3. Add a migration to generate the DDL (if not already present):
18+
```bash
19+
dotnet ef migrations add InitialCreate
20+
```
21+
22+
4. Generate the SQL script for the schema:
23+
```bash
24+
dotnet ef migrations script
25+
```
26+
27+
5. Inspect the generated SQL script to see how EF Core maps the one-to-many relationship in YDB.

0 commit comments

Comments
 (0)