|
1 | 1 | # DotNetCore Entity Framework Core provider for KingbaseES for R6 V008R006C008B0014 |
2 | 2 |
|
3 | | -DotNetCore.EntityFrameworkCore.KingbaseES is the open source EF Core provider for KingbaseES. It allows you to interact with KingbaseES via the most widely-used .NET O/RM from Microsoft, and use familiar LINQ syntax to express queries. |
| 3 | +[](https://github.com/dotnetcore) |
| 4 | +[](https://www.nuget.org/packages/DotNetCore.EntityFrameworkCore.KingbaseES) |
| 5 | +[](https://www.nuget.org/stats/packages/DotNetCore.EntityFrameworkCore.KingbaseES?groupby=Version) |
4 | 6 |
|
5 | | -The provider looks and feels just like any other Entity Framework Core provider. Here's a quick sample to get you started: |
| 7 | +`DotNetCore.EntityFrameworkCore.KingbaseES` is an open source Entity Framework Core provider for KingbaseES. It supports you to interact with KingbaseES via EFCore, the most widely-used .NET O/RM from Microsoft, up to its latest version, and use familiar LINQ syntax to express queries. |
6 | 8 |
|
7 | | -```csharp |
8 | | -await using var ctx = new BlogContext(); |
9 | | -await ctx.Database.EnsureDeletedAsync(); |
10 | | -await ctx.Database.EnsureCreatedAsync(); |
| 9 | +## Getting Started |
11 | 10 |
|
12 | | -// Insert a Blog |
13 | | -ctx.Blogs.Add(new() { Name = "FooBlog" }); |
14 | | -await ctx.SaveChangesAsync(); |
| 11 | +### 1. Project Configuration |
15 | 12 |
|
16 | | -// Query all blogs who's name starts with F |
17 | | -var fBlogs = await ctx.Blogs.Where(b => b.Name.StartsWith("F")).ToListAsync(); |
| 13 | +Ensure that your `.csproj` file contains the following reference: |
18 | 14 |
|
19 | | -public class BlogContext : DbContext |
20 | | -{ |
21 | | - public DbSet<Blog> Blogs { get; set; } |
| 15 | +```xml |
| 16 | +<PackageReference Include="DotNetCore.EntityFrameworkCore.KingbaseES" Version="6.0.22" /> |
| 17 | +``` |
22 | 18 |
|
23 | | - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
24 | | - => optionsBuilder.UseKdbndp(@"host={host};port={port};database={database};username={username};password={password};"); |
25 | | -} |
| 19 | +### 2. Services Configuration |
26 | 20 |
|
27 | | -public class Blog |
| 21 | +Add `DotNetCore.EntityFrameworkCore.KingbaseES` to the services configuration in your the `Startup.cs` file of your ASP.NET Core project: |
| 22 | + |
| 23 | +```csharp |
| 24 | +public class Startup |
28 | 25 | { |
29 | | - public int Id { get; set; } |
30 | | - public string Name { get; set; } |
| 26 | + public void ConfigureServices(IServiceCollection services) |
| 27 | + { |
| 28 | + // Replace with your connection string. |
| 29 | + var connectionString = "host={host};port={port};database={database};username={username};password={password};"; |
| 30 | + |
| 31 | + // Replace 'YourDbContext' with the name of your own DbContext derived class. |
| 32 | + services.AddDbContext<YourDbContext>( |
| 33 | + dbContextOptions => dbContextOptions |
| 34 | + .UseKdbndp(connectionString) |
| 35 | + ); |
| 36 | + } |
31 | 37 | } |
32 | | -``` |
| 38 | +``` |
| 39 | + |
| 40 | +### 3. Sample Application |
| 41 | + |
| 42 | +Check out our [Basic Test](https://github.com/dotnetcore/EntityFrameworkCore.KingbaseES/tree/main/test/KingbaseES.BasicTest) for an example repository that includes an ASP.NET Core MVC Application. |
| 43 | + |
| 44 | +There are also many complete and concise console application samples posted in the issue section (some of them can be found by searching for `Program.cs`). |
| 45 | + |
| 46 | +### 4. Read the EF Core Documentation |
| 47 | + |
| 48 | +Refer to Microsoft's [EF Core Documentation](https://docs.microsoft.com/en-us/ef/core/) for detailed instructions and examples on using EF Core. |
| 49 | + |
| 50 | +## Scaffolding / Reverse Engineering |
| 51 | + |
| 52 | +Use the [EF Core tools](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) to execute scaffolding commands: |
| 53 | + |
| 54 | +``` |
| 55 | +dotnet ef dbcontext scaffold "Server=localhost;User=root;Password=1234;Database=ef" "DotNetCore.EntityFrameworkCore.KingbaseES" |
| 56 | +``` |
| 57 | + |
| 58 | +## Contribute |
| 59 | + |
| 60 | +One of the easiest ways to contribute is to report issues and participate in discussions. You can also contribute by submitting pull requests with code changes and supporting tests. |
| 61 | + |
| 62 | +We are always looking for additional core contributors. If you got a couple of hours a week and know your way around EF Core and KingbaseES, give us a nudge. |
| 63 | + |
| 64 | +## License |
| 65 | + |
| 66 | +[PostgreSQL license](https://github.com/dotnetcore/EntityFrameworkCore.KingbaseES/blob/main/LICENSE) |
0 commit comments