Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

ASP.NET Application - Insert Row in Azure SQL database

$
0
0
<div class="post-text" itemprop="text">

I am trying to insert a row in the Azure table and the getting an error Cannot POST '/tables/Sate_Customer\n

I am successfully able to insert in 'Customer' and 'State' tables but not in State_Customer table, all are in the same database . By the way there is a FK constraint on CustomerId and StateId columns in this table.

publicclassState_Customer{[JsonProperty(PropertyName="id")]publicstringStateCustomerId{set; get;}[JsonProperty(PropertyName="CustomerId")]publicstringCustomerId{set; get;}[JsonProperty(PropertyName="StateId")]publicstringStateId{set; get;}[JsonProperty(PropertyName="createdAt")][CreatedAt]publicDateTimeCreatedAt{set; get;}[JsonProperty(PropertyName="updatedAt")][UpdatedAt]publicDateTimeUpdatedAt{set; get;}[JsonProperty(PropertyName="deleted")][Deleted]publicboolDeleted{set; get;}}public async voidInsertStateCustomer(){List<string> custIds =newList<string>(){"b1f57a2e-aeb4-4709-8b9a-cc5f35c4195f","f3a9035a-9869-42b9-a415-a8fa0d689c60"};string stId ="899becd5-199e-43b4-a4cc-f8883d0b8102";foreach(string strCusId in custIds){State_Customer stCust =newState_Customer(){CustomerId= strCusId,StateId= stId };

            await stateCustomerTable.InsertAsync(stCust);}
</div> <div class="post-taglist"> </div>

Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>