I am using Visual Studio 2015 3 update. Some of the following steps may not be needed in a future version of Visual Studio.
Create an ASP.NET Core project (with .NET Core) using No Authentification .
In the Package Manager console, do one 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
"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 up to
ConfigureServices in startup.cs to services.AddMvc(); .
string connection = Configuration.GetConnectionString("DefaultConnection"); services.AddDbContext<YourContextName>(options => options.UseSqlServer(connection));
source share