Reputation: 3
I'm using the EFCodeFirst package with the MVCMusicStore sample application.
Everything worked fine when I was using the SQL Express database. However, after creating the DB in SQL Server 2008 and updating the connection string, all my queries return 0 records. SQL Profiler shows that the queries run, and I can copy the query into SSMS and it returns rows.
Here's a query and my connection string:
var genres = storeDb.Genres.ToList(); (returns a count of 0)
add name="MusicStoreEntities" connectionString="Data Source=.;initial catalog=MvcMovieStore;integrated security=True;multipleactiveresultsets=True;App=EntityFramework" providerName="System.Data.SqlClient"
Any thoughts on this behavior? It obviously connects to the database and executes the query which I can see in SQL Profiler.
Upvotes: 0
Views: 292
Reputation: 6463
If the query runs in SSMS and returns rows, but no rows are returned in your app, it must be that your app is not working against the same DB instance. I had the exact same situation when moving from SQL CE to Express.
What i ended up doing was connecting to the DB from the application, using the servers tab, and then copying the connection string.
Upvotes: 0
Reputation: 1140
Try putting in the name of the machine as for Data Source ... Data Source=MYMACHINE
Upvotes: 0