I try to do an insert in to n:n (SQL Azure based) related tables (UserSet and TenantSet) using the Entity Framework, but it fails with the error: “tables without a clustered index are not supported in this version of sql server”. I’ve used the model first approach to generate the SQL database, so the SQL Server database should be fine.
After extensive search it seems that the table UserTenant has no clustered index. The script that the Entity Framework generate contains (in my opinion) an error. The relevant part of the script is:
Creating primary key on [User_UserId], [Tenant_TenantId] in table ‘UserTenant’
ALTER TABLE [dbo].[UserTenant] ADD CONSTRAINT [PK_UserTenant] PRIMARYKEY NONCLUSTERED ([User_UserId], [Tenant_TenantId] ASC); GO
Of course the NONCLUSTERED parameter should me CLUSTERED. Change that and run the script again.
That’s all, hope the Entity Framework team resolves this what looks like a bug.
I have a MVC 4 applications that calls a Web Api REST service. The webservice retrieves the values from a Windows Azure database using the Entity Framewok. For some reason a call to get a user from the web api fails. After inspecting the respons with the Fiddler2, I saw this error:
HTTP/1.1 500 Internal Server Error
ExceptionMessage=The ‘ObjectContent`1′ type failed to serialize the response body for content type ‘application/json; charset=utf-8′.
ExceptionMessage=Error getting value from ‘Tenant’ on ‘System.Data.Entity.DynamicProxies.User_A66506F1AD16B9BC58E2CE2527D9CEDD7F1AFFBF3191ECC41B3556′.
The strange thing is, that sometimes the call is made correctly. I’m running the application locally on my development workstation and especially when I step through the code, the call is miraculously completed correctly.
After hours of search I read in Professional C# 2012 and .NET 4.5that there are different setting in the way the object loads from the database using the Entity Framework. The setting from your datacontext must be set to LazyLoadingEnable = false. So my code looks as follows:
var db = new BsoDataModelContainer(); db.Configuration.LazyLoadingEnabled = false;
New to the Windows Communications Foundation (WCF) I’ve programmed some code in Visual Studio 2010 that should make use of my SQL Azure database that is hosted by Microsoft. I programmed the interfaces and exposed the services GetPresence and SetPresence . When testing the services with WCFTest.exe, all exposed services are working fine.
So I took my Windows Phone 7 app and right-clicked in the solution explorer on my Windows Phone app project and choose add service reference. Named the service and after selecting the correct service (that was correctly visible), the reference was added. I clicked on view object in browser, and the objectbrowser didn’t show my service reference at all. Double checked everything (as I doubt myself as a beginner the most) but no solution. Deleted the reference, added again: same issue.
To make a long (many hours) story short: Fortunately the solution is (as always) simple: – Delete the service reference – Close Visual Studio (this part is crusial !) – Reopen Visual Studio – Add the service reference again – Everything should be working fine now Since I’ve had the problem on different PC’s, I’m fully patched, this must be a bug in de Microsoft Visual Studio 2010 (version 10.0.40219.1 SP1Rel)
When is Visual Studio 2010 SP2 coming, or do I have to upgrade to Visual Studio 2012?