Skip to content

Instantly share code, notes, and snippets.

Created March 2, 2016 22:54
What would you like to do?
This file will allow you to pass a connection string as a parameter in powershell
using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace YourDbContextNameSpace
public class Startupupdate
public Startupupdate()
// Set up configuration sources.
var builder = new ConfigurationBuilder()
Configuration = builder.Build();
public IConfigurationRoot Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
var connection = Configuration["UpdateConnectionString"];
// Add framework services.
.AddDbContext<YourDbContext>(options => options.UseSqlServer(connection));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment