>>>>There's nothing stopping you from using Code First with an existing database.
>>>>
>>
>>>
>>>A tutorial on doing Code First to an existing database can be found here:
http://msdn.microsoft.com/en-us/data/jj200620>>
>>Thanks Rob, I'll check that out.
>>
>>However, I don't think that my problem is that I didn't use Code First (but it may be that in using database First I have mis-configured something),
>
>That is probably the case. Your context (the Uow property based off your code) should have a Database property with the connection information in it. Set a breakpoint in the debugger and confirm that your connection is correct. You may also want to try logging the requests that it is doing:
http://msdn.microsoft.com/en-us/data/dn469464.aspx.
Great! That pointed out that I hadn't set my connectionstring in the web.config file. Now that I've set that properly I'm at least getting something back on the web page, albeit it's an error :(
"innerException":{"message":"An error has occurred.","exceptionMessage":"Invalid object name 'dbo.ScanCode'."
This is interesting as my table is actually called ScanCodes (with an "s" on the end). So somewhere in the EF (I guess) it is not mapping the table names correctly?
< later >
I found it! The course suggested using this code:
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
Which I guess worked for his database, but because my tables are pluralized it messed me up.
So I think I've got it going now! :)