I am using Visual Studio 2015 Update 3. Some of the following steps might not be needed in the future release of Visual Studio.
Create ASP.NET Core (with .NET Core) project with No Authentification
.
In Package Manager Console, execute each of the following, one after the other.
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Tools -Pre
Install-Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc -Pre
- Add the following to the
"tools":{}
defined in project.json
.
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview2-final",
- Add the following to
appsettings.json
.
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=YourDatabaseName;Trusted_Connection=True;MultipleActiveResultSets=true"
},
- Add the following to
ConfigureServices
in startup.cs
right before services.AddMvc();
.
string connection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<YourContextName>(options => options.UseSqlServer(connection));