dotnet / dotnet/efcore

dotnet new dbcontext

Open
#28,681 0 comments 0 reactions 0 assignees View on GitHub
area-tools
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Now that we have a place for `dotnet new` templates, we should consider adding other ones.

I'm not sure how valuable it would be, but in EF6, we had a VS item template that gave you an empty DbContext class. It looked like this: (and added a connection string to App.config)

```cs
using System;
using System.Data.Entity;
using System.Linq;

namespace ConsoleApp1
{
public class MyDbContext : DbContext
{
// Your context has been configured to use a 'MyDbContext' connection string from your application's
// configuration file (App.config or Web.config). By default, this connection string targets the
// 'ConsoleApp1.MyDbContext' database on your LocalDb instance.
//
// If you wish to target a different database and/or database provider, modify the 'MyDbContext'
// connection string in the application configuration file.
public MyDbContext()
: base("name=MyDbContext")
{
}

// Add a DbSet for each entity type that you want to include in your model. For more information
// on configuring and using a Code First model, see http://go.microsoft.com/fwlink/?LinkId=390109.

// public virtual DbSet MyEntities { get; set; }
}

//public class MyEntity
//{
// public int Id { get; set; }
// public string Name { get; set; }
//}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.