SQLite reference in ASP.NET 5 WebApp - asp.net

App version - ASP.NET 5 beta7 build. Entity 7. OS Win x64.
I have a problem with attaching Sqlite to my app. I'm recieving Unable to load DLL 'sqlite3' (System.DllNotFoundException) or IncorrectFormat (System.BadImageFormatException) Errors.
It seems that app can't find SQLite dll & lacks proper reference.
When switching between dnx versions, errors change (tried in both clr & coreclr). Errors - Former for x86, latter for x64. However, in both instances dnx & sqlite versions are matched.
My global.
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta7",
"runtime": "clr",
"architecture": "x64"
}
}
My project.json partial.
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
"Microsoft.Framework.Logging": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
"Microsoft.AspNet.Session": "1.0.0-beta7",
"EntityFramework.SqlServer": "7.0.0-beta7",
"EntityFramework.Commands": "7.0.0-",
"EntityFramework.Sqlite": "7.0.0-beta7",
"sqlite": "3.8.4.2" (Nuget)
},
There is sqlite3.dll file in root but added reference just transforms into Nuget dependency 3.8.8.x within VS15.
Startup.cs partial.
public void ConfigureServices(IServiceCollection services) {
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<EF7oakContext>(options => options.UseSqlite(Configuration["SqliteString"])); }
... points to config.json.
"Data Source=<path>\\<DBname>.sqlite;"
I tried configuration within Context but if I understand correctly, that's just duplicating config.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseSqlite("Data Source=<path>\\<dbname>.sqlite;"); }
Simple custom Seed.cs.
public static void Seed(this IApplicationBuilder app) {
var context = app.ApplicationServices.GetService<MyContext>();
if (!context.People.Any()) {
context.People.AddRange(
new Sth { a = "a", b = "b" }
(...)
);
context.SaveChanges(); }
(...)
}
I checked Stack-link-1 and Stack-link-2, but solutions given there are not working.
Recap:
Matched sqlite3 version added as app reference. Used dnvm use [version]
Downloaded latest sqlite (sqlite-link) and put it in my app folder with unchanged name
With each runtime - packages restored with dnu restore
I want to match platform build options for sqlite, but there is no option in VS15, per #B. Clay Shannon similar problem from link no.1 above (earlier ASP v.)
App works with local SQL Server DB.
Migrations working.
I would appreciate any help or even loose suggestions.

Related

ASP.NET Core 1 and Entity Framework (Npgsql) breaks Startup class and says: app.UseMvc method not available

I want to use the Entity Framework 7 in my ASP.NET Core 1 application to connect to a PostgreSQL database.
If I add EntityFramework.Commands (7.0.0-beta5) and EntityFramework7.Npgsql (3.1.0-rc1-3) to my project.json file:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
"EntityFramework7.Npgsql": "3.1.0-rc1-3"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
I get errors in my Startup.cs
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
namespace Suplim.Web.Platform
{
public class Startup
{
public IConfiguration Configuration { get; set; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage(ErrorPageOptions.ShowAll);
}
else
{
app.UseErrorHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
Then Visual Studio says that in my Startup.Configure() method it can not find the methods:
app.UseBrowserLink
app.UseErrorPage
app.UseErrorHandler
app.UseStaticFiles
app.UseMvc
It says
Core DNX 4.5.1 not available
Core DNX Core 5 available
But both packages are loaded and available in the Visual Studio references structure (DNX 4.5.1 and DNX Core 5).
If I remove the EntityFramework.Commands and EntityFramework7.Npgsql packages everything works fine.
Why does the Entity Framework affect my Startup class? Are the versions incompatible (beta5 and rc1-final)? If yes what can I do?
I do not understand the problem.
You are using an rc1 package for EF and beta5 for anything else. You can't mix package versions. Move everything to rc1 (beta5 is a thing of the past) and use the rc1 runtime (dnx) otherwise things will break.
I have already tried to set the same version to all packages but some packages are still beta-* and others are rc1-final. These are the newest packages (I removed the EntityFramework7.Npgsql and other not needed packages for testing):
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final"
},
And my global.json is now:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-final",
"runtime": "clr",
"architecture": "x86"
}
}
Now it can not find the EntityFramework.Commands and Microsoft.AspNet.Mvc packages (both with different version number than 1.0.0) in the DNX 4.5.1 reference. In the DNX Core 5 reference it finds nothing, all packages are unresolved.
It is like the old DLL hell ...
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"
needs to be changed to
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"
As the other responder says you are mixing and matching. You should have everything on the same version or don't use it.

ASP.NET MVC running Entity Framework command on the command line

I want to run dnx commands from command line in Visual studio, but it does not work.
If I type the command:
dnx ef
I get the error:
System.InvalidOperationException: No service for type 'Microsoft.Dnx.Runtime.IApplicationEnvironment' has been registered.
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Data.Entity.Commands.Program..ctor(IServiceProvider dnxServices)
My project.json contains this:
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-beta8",
"Microsoft.Framework.SecretManager": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
DNX version:
Microsoft .NET Execution environment
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
DNVM version:
1.0.0-rc1-15540
DNVM list:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 clr x64 win
* 1.0.0-rc1-update1 clr x86 win default
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
I figured it out.
If you get errors like this, it probably if because of wrong dependencies.
They need to match your environment and other dependencies.
I installed the lates of them all and it worked.
This is my final dependencies:
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"Microsoft.Framework.SecretManager": "1.0.0-beta8"
},

Target specific framework in Class Library (Package)

I am attempting to use the new Class Library (Package) project in VS 2015.
I would like to target dnx451, so my package.json looks like this:
{
"version": "1.0.0-beta-1",
"description": "Foo",
"authors": [ "Foo" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"Newtonsoft.Json": "8.0.1",
"Microsoft.AspNet.Razor": "4.0.0-rc1-final",
"Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc1-final",
"System.Net.Http": "4.0.1-beta-23516"
},
"frameworks": {
"dnx451": { }
}
}
Build is fine, and I get:
Recaptcha-dnxcore -> C:\Users\Epic\Documents\artifacts\bin\Foo\Release\Foo.1.0.0-beta-1.nupkg
Now I create a web project and edit its project.json file so that it targets only the dnx451 framework:
"frameworks": {
"dnx451": { }
},
When I add a reference to my Foo package, I get an error:
The dependency Foo 1.0.0-beta-1 in project WebApplication7 does not support framework DNX,Version=v4.5.1.
How can I create a Nuget package from a Class Library (Package) project that supports dnx451?
Per the comment below, here is the full project.json of the web app:
{
"userSecretsId": "aspnet5-WebApplication7-0b4c05f0-6435-486b-9738-1b6aa3daee2c",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"System.Net.Http": "4.0.1-beta-23516",
"Foo": "1.0.0-beta-1"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
I followed the same procedure as mentioned in your question
I created both class library and web project in same solution, everything worked fine.
Since your are more focused on making it NuGet package target to dnx451. I created another web application in separate solution, yes it throws errors because NuGet packages named are many "Foo". I guess due to this restoring of packages is given issue as its referring to Global NuGet feed.
Then I tried referring "Foo" Nuget package locally using this link How to install a Nuget Package .nupkg file locally?
Ensure that newly create local Package Source should be on TOP and Offical NuGet second place.
After this, I restored web application in separate solution, it build fine and run properly also. Even I installed this NUGET in Console apps also
Hope this works out.
The class library should also have it's own project.json and define the frameworks that it supports:
"frameworks": {
"dnx451": { }
}
Don't add the version Number if you add a reference to a project, because it will search for the package on any Nugget feed.
Just add a reference to Foo, like this:
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"System.Net.Http": "4.0.1-beta-23516",
"Foo": ""
},
Have a look at this answer.
You can only add a direct reference to your class library project only if both projects are in the same solution.
If your projects are not in the same solution you have to go to your class library project properties, open Build tab and check Produce outputs on build option
NuGet package will be created in {SolutionDir}\artifacts\bin{ProjectName}{Configuration} directory on each project build.
To use the library, publish NuGet package to nuget.org or any other NuGet feed and add it to your project using Visual Studio (References ~> Manage NuGet Packages...) or to dependencies property in project.json.

Add dll to MVC6 or use old web service

I need to reference a dll which calls an old web service (not svc, but the older one). I'm not quite sure how to go about doing that. I'm using the RC1 version. I could call the web service directly but I'm not sure how to do that either in MVC6.
If I add the dll directly I get the error:
The name '*' does not exist in the current context
FieldOps.DNX Core 5.0
Here's what part of my project.json looks like where the library added is called "MyLibrary":
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Runtime.Serialization": "4.0.0.0",
"System.ServiceModel": "4.0.0.0"
},
"dependencies": { "MyLibrary": "2.2.0" }
},
"dnxcore50": {
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.ServiceModel.Primitives": "4.1.0-beta-23516",
"System.ServiceModel.Http": "4.0.11-beta-23516",
"System.ServiceModel.NetTcp": "4.1.0-beta-23516",
"System.ServiceModel.Duplex": "4.0.1-beta-23516",
"System.ServiceModel.Security": "4.0.1-beta-23516",
"System.Net.NameResolution": "4.0.0-beta-23516",
"System.Net.Security": "4.0.0-beta-23516",
"System.Security.Principal.Windows": "4.0.0-beta-23516",
"System.Diagnostics.Tools": "4.0.1-beta-23516"
}
}
},

Unable to get Session working ASP

Using VS 2015 with beta 7 of MVC 6 I am having issues getting Session configured for use in my web application.
When I create a new ASP.NET Web Application project I choose the Web Application ASP.NET 5 Preview Template.
I then edited the Startup.cs by adding the following line:
services.AddCaching();
I then added the following line:
services.AddSession();
At that point the editor prompted me to add a reference to this depencency:
"Microsoft.AspNet.Session": "1.0.0-beta8"
After doing so I get the following errors:
Error CS7069 Reference to type 'IConfigurationProvider' claims it is defined in 'Microsoft.Framework.Configuration.Abstractions', but it could not be found WebApplication1.DNX 4.5.1 c:\users\texasmike\documents\visual studio 2015\Projects\SessionTesting\src\WebApplication1\Startup.cs 29
Error CS7069 Reference to type 'IConfigurationProvider' claims it is defined in 'Microsoft.Framework.Configuration.Abstractions', but it could not be found WebApplication1.DNX Core 5.0 c:\users\texasmike\documents\visual studio 2015\Projects\SessionTesting\src\WebApplication1\Startup.cs 29
I have attempted a thorough search but haven't found any answers.
Here is the complete Startup.cs:
using Microsoft.AspNet.Authentication.Facebook;
using Microsoft.AspNet.Authentication.MicrosoftAccount;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using WebApplication1.Models;
using WebApplication1.Services;
namespace WebApplication1
{
public class Startup
{
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
// This reads the configuration keys from the secret store.
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
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)
{
// Add Entity Framework services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// Configure the options for the authentication middleware.
// You can add options for Google, Twitter and other middleware as shown below.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
services.Configure<FacebookAuthenticationOptions>(options =>
{
options.AppId = Configuration["Authentication:Facebook:AppId"];
options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
});
services.Configure<MicrosoftAccountAuthenticationOptions>(options =>
{
options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"];
options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"];
});
// Add MVC services to the services container.
services.AddMvc();
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
// services.AddWebApiConventions();
// Register application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
// Caching
services.AddCaching();
// Session
services.AddSession();
}
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
// app.UseFacebookAuthentication();
// app.UseGoogleAuthentication();
// app.UseMicrosoftAccountAuthentication();
// app.UseTwitterAuthentication();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
// Uncomment the following line to add a route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
}
}
}
Here is the complete project.json:
{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-WebApplication1-36d27e1d-a781-4628-91dc-8a80cb46fd14",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta7",
"EntityFramework.SqlServer": "7.0.0-beta7",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.Session": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
"Microsoft.Framework.Logging": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.Framework.Logging.Debug": "1.0.0-beta7",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}

Resources