2

I am going through the MvcMusicStore tutorial on the www.asp.net website.

I am able to use Entity Framework Core 2.0 and migrations to create a DB in localDb. Here is the connection string from that in appsettings.json:

"MvcMovieContext": "Server=(localdb)\\mssqllocaldb;Database=MvcMovieContext-19840e0a-5fb4-409c-9f38-7f2946cd3937;Trusted_Connection=True;MultipleActiveResultSets=true",

When ever I do these tutorials I usually at this point once the DB is created and everything works switch to SQL Server Express, because this is how I actually develop my projects.

So Entity Framework checks the new connection string, doesn't see the DB exists, and creates the new DB based on the Model.

But I can't seem to get the connection string to SQL Express working.

Here is what I have tried so far:

"MvcMovieContext": "Server=MyComputerName\\SQLEXPRESS;Database=MvcMovie;Trusted_Connection=True;MultipleActiveResultSets=true"

and

"MvcMovieContext": "Data Source=.\\SQLEXPRESS;Initial Catalog=MvcMovie;Integrated Security=True;MultipleActiveResultSets=true"

Both give the same result. The dreaded message:

SqlException: Cannot open database "MvcMovie" requested by the login. The login failed. Login failed for user 'Domain\smiller'.

I installed SQL Server Express in Mixed Mode so Windows Authentication works and I made my 'Domain\smiller' account a DbCreater in Server Roles.

Just can't seem to get it.

1 Answer 1

3

I needed to run:

Update-Database

I went through this last year: Why is dotnet ef not able to create a database against SQL Server Express?

It seems I never learn.

Sign up to request clarification or add additional context in comments.

1 Comment

I've banged my head on the desk all day for something so stupid simple. Microsoft should really put that in their sample instructions. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.