I am having trouble creating DB in SQL Server Express with Entity Framework Core 2.0

entity-framework-core sql-server-express

Question

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
0
12/20/2017 3:51:22 PM

Popular Answer

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.

1
12/20/2017 5:15:53 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow