I created a table in an Azure Table Storage and added a few records using my Entity class derived from TableEntity . After this I added two more properties to this class and tried to insert more records, but looks like the new fields are not added to the storage, and only the old fields are written and read. Am I missing something? I have to do something more to change the layout of the table?
thanks for the info but in the end I found that the problem was another. I used Vs to create the properties in the class, and doing this Vs created properties add an internal setter.
Looks like that in this situation The Azure Storage client simply ignore these properties not creating the fields not writing and not reading, giving no errors at all.
Removed the internal keyword started to work correctly.
First, I want to make sure that I understand your scenario. You modified the existing entity class by adding two more properties, then added new entities in the table. You were not able to see two newly added properties, but only able to update/retrieve the old properties. If that is the scenario that you are trying to implement, check the following. You should be able to add new properties.
Add new properties in the class that you derived your entity from TableEntity
class. Optional1
and Optional2
are new properties that you are trying to add.
public class CustomerEntity : TableEntity
{
public CustomerEntity() { }
public CustomerEntity(string lastName, string firstName)
{
this.PartitionKey = lastName;
this.RowKey = firstName;
}
public string Email { get; set; }
public string CellPhoneNumber { get; set; }
public string Optional1 { get; set; }
public string Optional2 { get; set; }
}
}
Make sure you set Optional1
and Optional2
values. See the sample code below.
var customer = new CustomerEntity(LastName, FirstName)
{
Email = Email,
CellPhoneNumber = cellPhoneNumber,
Optional1 = optional1,
Optional2 = optional2,
}
TableOperation insertOperation = TableOperation.Insert(customer);
TableName.Execute(insertOperation);
Note: I have not compiled the above code so there may be typos and etc.
Thanks, Aung
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With