Hi,
I've got a couple of Linq to SQL entities which are causing me problems:
[Table(Name = "ViewName")]
[InheritanceMapping(Code = false, Type = typeof(Entity1), IsDefault = true)]
[InheritanceMapping(Code = true, Type = typeof(Entity2))]
public class Entity1
{
[Column(AutoSync = AutoSync.OnInsert, DbType = "uniqueidentifier NOT NULL", IsPrimaryKey = true, IsDbGenerated = true)]
public Guid Bssid { get; set; }
// other properties
[Column(AutoSync= AutoSync.OnInsert ,DbType = "Int NOT NULL IDENTITY", IsDbGenerated = true)]
public int NewSslid { get; set; }
}
public class Entity2 : Entity1
{
public Entity2()
{
Discriminator = true;
_options = new EntitySet<Entity3>();
}
}
The entities are using an updatable view rather than a database table as there are about 150 fields spread across two tables. The view runs with all CRUD functions working as they should, but I get the following error when trying to Insert either entity type to the database:
System.InvalidOperationException : Member AutoSync failure. For members to be Auto-Synced after insert, the type must either have an auto-generated identity, or a key that is not modified by the database after insert.
The DB table for Entity1 uses a PK and a separate field (NewSslid) as the identity - which in turn is used as the PK on Entity2 field.
Can anyone point me in the right direction to getting this error sorted?