Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

LocalDb login fails

$
0
0

There's not an appropriate sub-forum under .NET so posting here.  If there is a better place please advise how to get to it.

LocalDB with EntityFramework 6 migrations.  ASP.NET MVC5 code first project.  VS 2013

I'm working through Tom Dykstra Getting Started with EF6 using MVC5http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc.

I'm logged in as 'MyUser' who has sysadmin rights to the SQL Server 2012 EXPRESS installation.

When I run either 'databaseInitializer' or a migrations 'update-database' it fails with this error:

Cannot open database "ContosoUniversity2" requestedby the login.The login failed.
Login failed for user 'MyMachine\MyUser'.

From the web.config

<connectionStrings>
   
<addname="SchoolContext"connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;"providerName="System.Data.SqlClient"/>
</connectionStrings>

<contexts>
     
<contexttype="ContosoUniversity.DAL.SchoolContext, ContosoUniversity">
       
<databaseInitializertype="ContosoUniversity.DAL.SchoolInitializer, ContosoUniversity"/>
     
</context>
</contexts>

If I run VS 2013 as admin it successfully creates the DBs in the root of the Admin's User profile. If I then copy those DBs to the MyUser's user profile root and run VS 2013 not as admin the'databaseInitializer' or a migrations 'update-database' work on the now pre-existing DBs.

If I replace Initial Catalog with AttachDbFilename it creates the DB's in the apps App_Data folder proving that MyUser has create DB rights.  MyUser obviously has full rights to its own user profile folder.

See full write up at http://stackoverflow.com/questions/21592062/ef6-migrations-localdb-update-database-login-failed

I've seen other posts on the web about this problem with LocalDb.  Can anyone at the Microsoft Team look into this error?  Anyone else have any insight as to why LocalDb can't create databases for anyone but admin.


ts1278


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>