EFCodeFirst CTP 5 won't populate the model with any records - the queries run fine however
I'm using the EFCodeFirst package with the MVCMusicStore sample application.
Everythi开发者_如何学JAVAng 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.
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.
Try putting in the name of the machine as for Data Source ... Data Source=MYMACHINE
精彩评论