开发者

Entity Framework Connection Error "Cannot open database "DB" requested by the login. The login failed"

I am using Entity Framework in .NET MVC 3.0 and use Code First method. And I used a .MDF file for database and also use "DropCreateDatabaseIfModelChanges" to generate database automatically after every change.

My application works correct, but when I open database from Server Explorer in VS, then my application gives an error:

Cannot open database "DB" requested by the login. The login开发者_Go百科 failed. Login failed for user 'Mahdi-PC\Mahdi

Could you help me?!


Not sure, but... In the Data Connection dialog have you got the "Data Source" set to "Microsoft SQL Server" - I think you might need to change it to be "Microsoft SQL Server Database File"


I got this error when I had the mdf file open in SQL SMS 2012 while I was trying to update-database in Visual Studio 2013 Package Manager Console. In my case VS 2013 and SQL SMS 2012 could not share the mdf file. Once I closed SQL SMS I was able to update the mdf file ... that was whack ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜