views:

36

answers:

1

Hi,

I am working on a Webforms app (in VS 2010, .net 4.0, VB) that uses SQL2008, Linq2Sql, Domain Services and Dynamic Data.

My problem is that when I try to insert a new record, I get the error: "..CustomerId is required" but the ID is set as primary key and Identity in the database and the Customer entity in the L2S Datamodel is also marked as

<Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_CustomerId", AutoSync:=AutoSync.OnInsert, DbType:="Int NOT NULL IDENTITY", IsPrimaryKey:=true, IsDbGenerated:=true)> _

So there is no need to manually supply a CustomerId.

Anyone had the same experience? What am I doing wrong?

Thanks in advance for your help.

GM

Here is a little update: I added another project, basically the same setup as above but without a DomainService class. So it is just Linq2Sql and Dynamic data. I used the same database. The insert works fine, no hickups here. So it seems that the issue is with the Domain Service.

Any help would be appreciated.

Thanks GM

A: 

[Copying reply to the asp.net thread so this one gets closed as well]

Hi Gerhard,

Please take a look at this thread, which I think discusses the same issue. Well, it discusses two distinct issues and this is one of them. In short, the solution is to add a ScaffoldColumn(false) attribute on your ID property in the metadata class (the one generated when you created the web service).

Hope this helps, David

David Ebbo
Thanks David for your help. Tadding a ScaffoldColumn(false) attribute to the ID fields (Primary key in each table) solved the issue.
gm