Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection string is added in a different location than the templates #259

Closed
Tratcher opened this issue Jun 22, 2016 · 2 comments
Closed

Comments

@Tratcher
Copy link
Member

Tratcher commented Jun 22, 2016

If you use scaffolding to create a dbcontext while creating a controller it will add a connection string to appsettings.json and the code to read it in ConfigureServices. However, it's still using the location and APIs that were used in the RC1 templates and does not match the RC2 or RTM templates.

scaffolding:

            services.AddDbContext<WebApplication6FooContext>(options =>
                    options.UseSqlServer(Configuration["Data:WebApplication6FooContext:ConnectionString"]));
  "Data": {
    "WebApplication6FooContext": {
      "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=WebApplication6FooContext-d43134d2-a078-4fac-a02c-a871317c4236;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  }

template:

            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-WebApplication4-63f9d57e-b6e6-4a3a-950d-c82b28384751;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
@barrytang
Copy link

TFS Bug#235745

prafullbhosale added a commit that referenced this issue Jul 20, 2016
….json

Fixes #259
Added a newline in controllerWithActions.cshtml. Fixes #228
prafullbhosale added a commit that referenced this issue Jul 21, 2016
….json

Fixes #259
Added a newline in controllerWithActions.cshtml. Fixes #228
@Eilon
Copy link
Member

Eilon commented Aug 26, 2016

Approved for 1.0.0-preview2-update1.

@Eilon Eilon added this to the 1.0.0-preview2-update1 milestone Aug 26, 2016
prafullbhosale added a commit that referenced this issue Aug 29, 2016
….json

Fixes #259
Added a newline in controllerWithActions.cshtml. Fixes #228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants