Home > 5.0, ASP.NET, Core RC2, Entity Framework 7.0, Entity Framework Core > .net Core RC2–EntityFramework Database First

.net Core RC2–EntityFramework Database First

This is the updated version using RC2 for https://jefferytay.wordpress.com/2016/02/02/asp-net-vnext-entityframework-7-0-database-first-rc1/

You can refer to the full documentation at https://docs.efproject.net/en/latest/miscellaneous/configuring-dbcontext.html

Step by step guide:

  1. Starting with a blank project, add the following dependencies inside project.json

    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",

    If you are upgrading from RC1, I would suggest you create a brand new project and migrate the files rather than attempt to migrate the entire project

  2. Add the following inside tools
    "Microsoft.EntityFrameworkCore.Tools": {
         "version": "1.0.0-preview1-final",
         "imports": [
  3. ef command now no longer exists, you need to use dotnet ef

dotnet ef dbcontext scaffold -c UserDbContext -o Models -f "Data Source=.; Initial Catalog=user;User ID=user;Password=password" Microsoft.EntityFrameworkCore.SqlServer

Usage: dotnet ef dbcontext scaffold [arguments] [options]
  [connection]  The connection string of the database
  [provider]    The provider to use. For example, EntityFramework.MicrosoftSqlServer
  -a|–data-annotations           Use DataAnnotation attributes to configure the model where possible. If omitted, the output code will use only the fluent API.
  -c|–context <name>             Name of the generated DbContext class.
  -f|–force                      Force scaffolding to overwrite existing files. Otherwise, the code will only proceed if no output files would be overwritten.
  -o|–output-dir <path>          Directory of the project where the classes should be output. If omitted, the top-level project directory is used.
  –schema <schema>               Selects a schema for which to generate classes.
  -t|–table <schema.table>       Selects a table for which to generate classes.
  -e|–environment <environment>  The environment to use. If omitted, "Development" is used.
  -h|–help                       Show help information
  -v|–verbose                    Enable verbose output

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: