When I try to ask a service - I get an exception
Unable to load metadata for return type 'System.Linq.IQueryable'
Inet says that service can not find model files. But I use code-first, and have no such files.
I use Microsoft.Data.Services
.
You can say that my connection string is wrong.
But when I try to init myDbContext
, my database is created without tables.
No breakpoints after creation context have been hit.
What can I do???
You may be missing datamember attributes in fields and datacontract attribute in class.
It is best to have some light class between your db and wcf ,so that you can add special attributes or create complex entities to use in wcf endpoints.
Just info if you are missing something about EF Code First & WCF Data Service.
There are two assemblies for creating and consuming WCF Data Services in the .NET Framework 4: System.Data.Services.dll and System.Data.Services.Client.dll. If you try to use these with a DbContext and Code First classes, they won’t work out of the box. The issue is with DbContext, not Code First. DbContext didn’t exist when those assemblies were built, so they don’t understand it.
Resolution is either use ObjectContext (DbConext use ObjectcContext under the cover)
[OR]
Use March 2011 CTP that contained fixed-up assemblies (Microsoft.Data.Services.dll and Microsoft.Data.Services.Client.dll) that know how to work with the DbContext.
Checkout msdn article for details: