Mmm. Indeed, this (where Fax is marked as read only):
CustomerEntity newCustomer = new CustomersEntity();
newCustomer.CustomerId = "AAAA";
newCustomer.CompanyName = "AAAAAAAAAAAAAA";
newCustomer.Fields["Fax"].ForcedCurrentValueWrite("1122334455");
newCustomer.Fields["Fax"].IsChanged = true;
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.SaveEntity(newCustomer);
}
Generates this:
Query: INSERT INTO [Northwind].[dbo].[Customers] ([CustomerID], [CompanyName]) VALUES (@CustomerId, @CompanyName)
Parameter: @CustomerId : StringFixedLength. Length: 5. Precision: 0. Scale: 0. Direction: Input. Value: "AAAA".
Parameter: @CompanyName : String. Length: 40. Precision: 0. Scale: 0. Direction: Input. Value: "AAAAAAAAAAAAAA".
I never faced this, so, looking at the documentation here:
If you want to set an identity primary key column, you'll notice you can't do that because it is marked as read-only. Use the method entityObject.Fields[fieldindex or fieldname].ForcedCurrentValueWrite(value). See the reference manual for details about this method (EntityField2.ForcedCurrentValueWrite).
and here:
When you've selected a field which is not read-only by default (an identity field, a field of a database type which doesn't require a value (like SqlServer's Timestamp) or a computed column), you're able to make the field read-only by checking the Is readonly checkbox.
Seems that indeed the ForcedCurrentValueWrite is intended to a workaround for identity fields that for any reason you want to write. Also, the ReadOnly is designed for fields that are, in fact, read-only (calculated fields, timestamp, etc).
Why your field is marked as read only?
I'll try to find a workaround for you.