2015-09-15 61 views
3

新鲜的操作系统,新鲜vs 2015年,我所做的就是创建新的mvc项目并进行个人身份验证,并且一旦我尝试注册它就会给我那个错误(我编辑不了任何东西,我什么也没删)asp.net mvc 5试图注册新创建的网站时出现错误

Server Error in '/' Application.

The system cannot find the file specified

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:

Line 153: { Line 154: var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; Line 155: var result = await UserManager.CreateAsync(user, model.Password); Line 156: if (result.Succeeded) Line 157: {

Source File: c:\users****\documents\visual studio 2015\Projects\WebApplication5\WebApplication5\Controllers\AccountController.cs Line: 155

Stack Trace:

[Win32Exception (0x80004005): The system cannot find the file specified]

回答

1

您是否使用迁移创建数据库?

如果不是这样,在VS打开包管理器控制台(工具 - > NuGet包管理器 - >程序包管理器控制台)

在您必须启用与命令迁移命令行。

Enable-Migrations -EnableAutomaticMigrations

是运行命令

Update-Database

,并开始项目后

https://msdn.microsoft.com/en-us/data/jj591621.aspx

+0

它没有解决,命令下面的命令运行,据我知道,我只需要使用当我编辑代码的第一个数据库时迁移,但我甚至没有触及代码,我试图开箱,它不工作 – user3761832

+0

经过数小时的奋斗和几个解决方案的尝试。这一个为我工作,但只在第二次尝试。我想知道为什么这不是默认的。当然,下载Visual Studio并启动一个ASP.NET MVC项目的所有人都不会遇到这个障碍。这是否依赖于环境? – Goose

0

它看起来像教程要么跳过数据库创建部分或落后最新的VS 2013的模板。创建新的MVC项目时,数据库缺失。另外,该教程通过用户名注册用户,而项目希望您使用电子邮件地址。

1

请按照these tutorial。 您需要启用迁移,在模型中添加第一个迁移并更新数据库。

+0

这是一个界限[link-only answer](// meta.stackexchange.com/q/8231)。你应该扩大你的答案,在这里包含尽可能多的信息,并使用链接仅供参考。 – FrankerZ

3

我有同样的问题,我已经找到了解决的办法。在ConnectionString中存在的问题,它改变:

connectionString="Data Source(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20160303101342.mdf;Initial Catalog=aspnet-WebApplication3-20160303101342;Integrated Security=True" 

要:

connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=YourDatabaseName;Data Source=YourServerName" 

,它会工作没有任何其他变化

0

转到包管理器控制台

步骤1

enable-migrations 

步骤2执行以下命令

add-migrations InitialModel 

步骤3和最后一次运行

update database 
相关问题