Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WebApi not returning expected data
Message
De
19/06/2014 09:48:30
 
 
À
18/06/2014 18:35:33
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01602038
Message ID:
01602087
Vues:
53
>>>>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! :)
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform