Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rmloveland committed Jul 26, 2024
1 parent be2cd71 commit 19c1317
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/current/v24.2/build-a-csharp-app-with-cockroachdb-efcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,23 @@ This tutorial shows you how build a simple C# application with CockroachDB and t

{% include {{page.version.version}}/app/start-cockroachdb.md %}

## Create a .NET project
## Get the code

In your terminal, run the following commands:

{% include_cached copy-clipboard.html %}
~~~ shell
dotnet new console -o cockroachdb-efcore-test-app
git clone https://github.com/cockroachdb/efcore.pg.cockroach
~~~

{% include_cached copy-clipboard.html %}
~~~ shell
cd cockroachdb-efcore-test-app
cd efcore.pg.cockroach/examples/
~~~

The `dotnet` command creates a new app of type `console`. The `-o` parameter creates a directory named `cockroachdb-efcore-test-app` where your app will be stored and populates it with the required files. The `cd cockroachdb-efcore-test-app` command puts you into the newly created app directory.

## Install the EFCore driver

Install the latest version of the [EFCore driver](https://www.nuget.org/packages/EFCore/) into the .NET project using the built-in nuget package manager:

{% include_cached copy-clipboard.html %}
~~~ shell
dotnet add package EFCore
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
~~~

## Create a database
Expand Down Expand Up @@ -63,13 +57,11 @@ Now that you have set up your project and created a database, in this section yo

### Basic example

#### Get the code

Replace the contents of the `Program.cs` file that was automatically generated in your `cockroachdb-efcore-test-app` directory with the code below:
Edit the contents of the `Program.cs` file in the `efcore.pg.cockroach/examples` directory, which is shown below. Note that you will need to update the code with the username and password of the SQL user you created earlier.

{% include_cached copy-clipboard.html %}
~~~ c#
{% remote_include https://raw.githubusercontent.com/cockroachlabs/hello-world-csharp/main/basic.cs %}
{% remote_include https://raw.githubusercontent.com/cockroachdb/efcore.pg.cockroach/main/examples/Program.cs %}
~~~

#### Run the basic example
Expand Down

0 comments on commit 19c1317

Please sign in to comment.