score:0

You can't change attributes on the fly without using reflection. You may be able to do this in another fashion by handcoding your linq. I wouldn't advise changing the attributes on the fly, they are attributes by design and there may be unforeseen conscquencies for altering that.

score:1

Let me rephrase the question: you want to use the same object definitions on both sides, but on one side you want the identifier to be generated, while on the other side you want it to be inserted? The only way that I know of to do this is to use XML-based metadata instead of attribute-based. Unfortunately, as far as I know the visual DBML designer does not support XML metadata. However, you can use the SqlMetal tool to generate the XML, then modify the file for use on the other side of the web service.

You can get started using SqlMetal here: http://msdn.microsoft.com/en-us/library/bb386987.aspx

score:0

It is definitely the IsDbGenerated property that you need to look at, and not AutoSync.

I see you've described one scenario where you want to set the ID in the application. Is there actually another scenario where you need it to be auto-generated by the database? If not, you can just set IsDbGenerated = false, and populate with Guid.NewGuid() in your WCF service if/when you don't already have an ID from the client.

One of the advantages of using a rowguid instead of an identity column is that you're allowed to insert specific values into the rowguid column, but you don't have to. You can keep the column as a rowguid with DEFAULT NEWID(), but set IsDbGenerated = false in your service, and it will still work as long as you remember to actually populate the ID.


Related Articles