in Education by
I am working on vs 2010 and EF 4.1 with SQL server database. Below mentioned code works fine with local SQL server DB.(SQL 2008). But when I published the MVC application for windows AZURE cloud and SQL Azure it's giving below mentioned error. Why this error is only return SQL Azure (working with desktop SQL server 2008)? How to get rid of this? My repository code sample as below.The below mentioned error comes when callingCatalog.SaveChanges() method. using (var catalog = new DataCatalog()) { var retailSaleReturn = new RetailSaleReturn { ReturnQuantity = returnQuantity, Product = saleDetailObj.Product, Owner = owner, Provider = provider, }; //add to context Catalog.RetailSaleReturns.Add(retailSaleReturn); //save for db Catalog.SaveChanges(); } DbUpdateException is Like below : {"An error occurred while saving entities that do not expose foreign key properties for their relationships. The EntityEntries property will return null because a single entity cannot be identified as the source of the exception. Handling of exceptions while saving can be made easier by exposing foreign key properties in your entity types. See the InnerException for details."} InnerException is Like below : {"Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again."} StackTrace is Like below at System.Data.Entity.Internal.InternalContext.SaveChanges() at PawLoyalty.Data.Repositories.CustomersRepository.ReturnRetailOnlySales(Guid saleDetailId, Int32 returnQuantity, String providerKey, String ownerKey) in D:\PawLoyalty Module\PawLoyalty\PawLoyalty\PawLoyalty.Data\Repositories\CustomersRepository.cs:line 550 at PawLoyalty.Web.Areas.Providers.Controllers.CustomersController.ReturnRetailOnlySales(String providerKey, String ownerKey, String petKey, Guid saleDetailId, Int32 returnQuantity) in D:\PawLoyalty Module\PawLoyalty\PawLoyalty\PawLoyalty.Web\Areas\Providers\Controllers\CustomersController.cs:line 942 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.b__a() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
We have to create a clustered index on all the tables present in Azure SQL that we wish to add rows else the insert statement will always fail. CREATE UNIQUE CLUSTERED INDEX Idx_TableName ON TableName(yourGUIDColumn);

Related questions

0 votes
    Is there any way to stop a SQL Azure DB so that it doesn't charge anything towards our account? I don't ... cloud services and VM's. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I am trying to run the following SQL: INSERT INTO Suppliers ( [SupplierID], [CompanyName]) Select [SupplierID], [ ... is very slow. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    When should I use SQL Azure and when should I use table Storage? I was thinking, use table storage for transaction ... do you think? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I am creating a new read/write user on SQL Azure as follows: -- Connected to master create login [fred] ... doing wrong or missing? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I'm getting this error: The model item passed into the dictionary is of type System.Data.Entity. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I'm getting this error: The model item passed into the dictionary is of type System.Data.Entity. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am running aspnet_compiler as a post-build event, using the following command: aspnet_compiler.exe -v / - ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have an Azure table datastore and here's my model for one class: public class Product : ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    Could someone tell me how to learn Cloud Computing with no IT background? Select the correct answer from above options...
asked Jan 6, 2022 in Education by JackTerrance
0 votes
    I've created a BACPAC backup of my Azure SQZ database using the option "Export" in Azure management console. I ... written it already . Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I'm trying to make a web-based .NET application from scratch. I'm considering using Microsoft Azure to host it ... advice for using it. Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    Can't ping smtp.gmail.com. I've been using google smtp for email notification and it was working ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    How non clustered index point to the data? (a) It never points to anything (b) It points to a ... and Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Which one is true about clustered index? (a) Clustered index is not associated with table (b) Clustered index ... SQL topic in division Indexing and Hashing of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    What is the difference between Clustered and Non-clustered index?...
asked Dec 9, 2020 in Technology by JackTerrance
...