none
InsertOnSubmit - Specified cast is not valid RRS feed

  • Question


  • getting error: Specified cast is not valid on a simple Linq to SQL SubmitChanges method which follows InsertOnSubmit method. I dont how there can be a problem with any of the table rows - there is an int identity, 3 decimal columns, 3 strings and 2 dates.  This code was working yesterday. Since then I have added an additional index on the table being inserted into. After adding the index I opened up the .DBML file thinking maybe the designer.cs class has to be recreated.

    How do I determine what is causing the cast error?  The exception does not contain an innerexception. I cant step into the SubmitChanges and InsertOnSubmit methods. 

    What follows is some code and some call stack data returned by the exception.

    thanks,

         pcar.Models.pcarDataContext dc = new pcar.Models.pcarDataContext();
    
          foreach (string line in InLines)
          {
            if (line == "")
              continue;
            bool skipFlag = false ;
            string chOrdrnu = "" ;
    
            OrderBalanceRow row = new OrderBalanceRow();
            CsvString csv = new CsvString(line);
            row.SN = csv[0].ToString();
            row.Mbrnu = Decimal.Parse(csv[1].ToString());
            chOrdrnu = csv[2].ToString();
            row.BalAmt = Decimal.Parse(csv[3].ToString());
            row.LastName = csv[4].ToString();
            row.Derog = "";
            row.EntryDate = DateTime.Now;
            row.LastPayDate = DateTime.Now;
    
            row.Ordrnu = Decimal.Parse(chOrdrnu);
    
            dc.OrderBalanceRows.InsertOnSubmit(row);
            dc.SubmitChanges();
    



       at System.Data.Linq.IdentityManager.StandardIdentityManager.SingleKeyManager`2.TryCreateKeyFromValues(Object[] values, V& v)
       at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)
       at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)
       at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)
       at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)
       at System.Data.Linq.ChangeProcessor.BuildEdgeMaps()
       at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges()
       at pcar.Controllers.HomeController.LoadOrderBalance(String[] InLines) in C:\srdocs\pcar\pcar\Controllers\HomeController.cs:line 147
       at pcar.Controllers.HomeController.Upload(HttpPostedFileBase summary) in C:\srdocs\pcar\pcar\Controllers\HomeController.cs:line 61
       at lambda_method(ExecutionScope , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
    Wednesday, May 27, 2009 12:18 AM

Answers

  • The problem here is:

    	[Association(Name="AccountMasterRow_OrderBalanceRow",
          Storage="_AccountMasterRow", ThisKey="SN,Mbrnu", OtherKey="SN,Mbrnu", IsForeignKey=true)]

    And that the primary key for the AccountMasterRow class is not actually SN, Mbrnu.

    This has been fixed in .NET 4.0 and a hotfix is available for 3.5 SP1 that you can obtain via CSS.

    [)amien
    • Marked as answer by Steve Richter Thursday, May 28, 2009 3:01 PM
    Thursday, May 28, 2009 4:57 AM
    Moderator

All replies

  • It's having a problem with the association between OrderBalanceRow and and something else. Can you post the DBML fragment for OrderBalanceRow and any tables it is associated with?

    [)amien
    Wednesday, May 27, 2009 2:09 AM
    Moderator
  • Maybe my problem is the dbml designer.cs code has to be refreshed. I noticed that one of the key fields in that source code had the wrong case. ( the column had been lower case. I changed it at  some point so the 1st char was upper case. )  I changed the designer.cs code and tried again. Same error.

    How do I get Visual Studio to rebuild the dbml designer.cs source code?

    other info on the error : I was able to insert into my OrderBalance table using SqlCommand and ExecuteNonQuery.

    OrderBalanceRow has a foreign key relationship with AccountMasterRow. ( there are many orders for an account ). The keys to AccountMaster are SN and Mbrnu. The keys to OrderBalance is SN, Mbrnu, Ordrnu. SN is char(6). Mbrnu is decimal(5,0). Ordrnu is decimal(9,0).

    Not sure what fragment of code to post. Here is all the designer.cs file source code.

    thanks,

    #pragma warning disable 1591
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:2.0.50727.3074
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    namespace pcar.Models
    {
    	using System.Data.Linq;
    	using System.Data.Linq.Mapping;
    	using System.Data;
    	using System.Collections.Generic;
    	using System.Reflection;
    	using System.Linq;
    	using System.Linq.Expressions;
    	using System.ComponentModel;
    	using System;
    	
    	
    	[System.Data.Linq.Mapping.DatabaseAttribute(Name="pcar")]
    	public partial class pcarDataContext : System.Data.Linq.DataContext
    	{
    		
    		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
    		
        #region Extensibility Method Definitions
        partial void OnCreated();
        partial void InsertOrderBalanceRow(OrderBalanceRow instance);
        partial void UpdateOrderBalanceRow(OrderBalanceRow instance);
        partial void DeleteOrderBalanceRow(OrderBalanceRow instance);
        partial void InsertAccountMasterRow(AccountMasterRow instance);
        partial void UpdateAccountMasterRow(AccountMasterRow instance);
        partial void DeleteAccountMasterRow(AccountMasterRow instance);
        #endregion
    		
    		public pcarDataContext() : 
    				base(global::System.Configuration.ConfigurationManager.ConnectionStrings["pcarConnectionString"].ConnectionString, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public pcarDataContext(string connection) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public pcarDataContext(System.Data.IDbConnection connection) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public pcarDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public pcarDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public System.Data.Linq.Table<OrderBalanceRow> OrderBalanceRows
    		{
    			get
    			{
    				return this.GetTable<OrderBalanceRow>();
    			}
    		}
    		
    		public System.Data.Linq.Table<AccountMasterRow> AccountMasterRows
    		{
    			get
    			{
    				return this.GetTable<AccountMasterRow>();
    			}
    		}
    	}
    	
    	[Table(Name="dbo.OrderBalance")]
    	public partial class OrderBalanceRow : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _RcdID;
    		
    		private string _SN;
    		
    		private decimal _Mbrnu;
    		
    		private decimal _Ordrnu;
    		
    		private decimal _AmtDue;
    		
    		private System.DateTime _EntryDate;
    		
    		private System.DateTime _LastPayDate;
    		
    		private string _derog;
    		
    		private string _LastName;
    		
    		private EntityRef<AccountMasterRow> _AccountMasterRow;
    		
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnRcdIDChanging(int value);
        partial void OnRcdIDChanged();
        partial void OnSNChanging(string value);
        partial void OnSNChanged();
        partial void OnMbrnuChanging(decimal value);
        partial void OnMbrnuChanged();
        partial void OnOrdrnuChanging(decimal value);
        partial void OnOrdrnuChanged();
        partial void OnBalAmtChanging(decimal value);
        partial void OnBalAmtChanged();
        partial void OnEntryDateChanging(System.DateTime value);
        partial void OnEntryDateChanged();
        partial void OnLastPayDateChanging(System.DateTime value);
        partial void OnLastPayDateChanged();
        partial void OnDerogChanging(string value);
        partial void OnDerogChanged();
        partial void OnLastNameChanging(string value);
        partial void OnLastNameChanged();
        #endregion
    		
    		public OrderBalanceRow()
    		{
    			this._AccountMasterRow = default(EntityRef<AccountMasterRow>);
    			OnCreated();
    		}
    		
    		[Column(Storage="_RcdID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int RcdID
    		{
    			get
    			{
    				return this._RcdID;
    			}
    			set
    			{
    				if ((this._RcdID != value))
    				{
    					this.OnRcdIDChanging(value);
    					this.SendPropertyChanging();
    					this._RcdID = value;
    					this.SendPropertyChanged("RcdID");
    					this.OnRcdIDChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_SN", DbType="NChar(6) NOT NULL", CanBeNull=false)]
    		public string SN
    		{
    			get
    			{
    				return this._SN;
    			}
    			set
    			{
    				if ((this._SN != value))
    				{
    					if (this._AccountMasterRow.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnSNChanging(value);
    					this.SendPropertyChanging();
    					this._SN = value;
    					this.SendPropertyChanged("SN");
    					this.OnSNChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Mbrnu", DbType="Decimal(5,0) NOT NULL")]
    		public decimal Mbrnu
    		{
    			get
    			{
    				return this._Mbrnu;
    			}
    			set
    			{
    				if ((this._Mbrnu != value))
    				{
    					if (this._AccountMasterRow.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnMbrnuChanging(value);
    					this.SendPropertyChanging();
    					this._Mbrnu = value;
    					this.SendPropertyChanged("Mbrnu");
    					this.OnMbrnuChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Ordrnu", DbType="Decimal(9,0) NOT NULL")]
    		public decimal Ordrnu
    		{
    			get
    			{
    				return this._Ordrnu;
    			}
    			set
    			{
    				if ((this._Ordrnu != value))
    				{
    					this.OnOrdrnuChanging(value);
    					this.SendPropertyChanging();
    					this._Ordrnu = value;
    					this.SendPropertyChanged("Ordrnu");
    					this.OnOrdrnuChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_AmtDue", DbType="Decimal(9,2) NOT NULL")]
    		public decimal BalAmt
    		{
    			get
    			{
    				return this._AmtDue;
    			}
    			set
    			{
    				if ((this._AmtDue != value))
    				{
    					this.OnBalAmtChanging(value);
    					this.SendPropertyChanging();
    					this._AmtDue = value;
    					this.SendPropertyChanged("BalAmt");
    					this.OnBalAmtChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_EntryDate", DbType="DateTime NOT NULL")]
    		public System.DateTime EntryDate
    		{
    			get
    			{
    				return this._EntryDate;
    			}
    			set
    			{
    				if ((this._EntryDate != value))
    				{
    					this.OnEntryDateChanging(value);
    					this.SendPropertyChanging();
    					this._EntryDate = value;
    					this.SendPropertyChanged("EntryDate");
    					this.OnEntryDateChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_LastPayDate", DbType="DateTime NOT NULL")]
    		public System.DateTime LastPayDate
    		{
    			get
    			{
    				return this._LastPayDate;
    			}
    			set
    			{
    				if ((this._LastPayDate != value))
    				{
    					this.OnLastPayDateChanging(value);
    					this.SendPropertyChanging();
    					this._LastPayDate = value;
    					this.SendPropertyChanged("LastPayDate");
    					this.OnLastPayDateChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_derog", DbType="NChar(10) NOT NULL", CanBeNull=false)]
    		public string Derog
    		{
    			get
    			{
    				return this._derog;
    			}
    			set
    			{
    				if ((this._derog != value))
    				{
    					this.OnDerogChanging(value);
    					this.SendPropertyChanging();
    					this._derog = value;
    					this.SendPropertyChanged("Derog");
    					this.OnDerogChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_LastName", DbType="NChar(30) NOT NULL", CanBeNull=false)]
    		public string LastName
    		{
    			get
    			{
    				return this._LastName;
    			}
    			set
    			{
    				if ((this._LastName != value))
    				{
    					this.OnLastNameChanging(value);
    					this.SendPropertyChanging();
    					this._LastName = value;
    					this.SendPropertyChanged("LastName");
    					this.OnLastNameChanged();
    				}
    			}
    		}
    		
    		[Association(Name="AccountMasterRow_OrderBalanceRow",
          Storage="_AccountMasterRow", ThisKey="SN,Mbrnu", OtherKey="SN,Mbrnu", IsForeignKey=true)]
    		public AccountMasterRow AccountMasterRow
    		{
    			get
    			{
    				return this._AccountMasterRow.Entity;
    			}
    			set
    			{
    				AccountMasterRow previousValue = this._AccountMasterRow.Entity;
    				if (((previousValue != value) 
    							|| (this._AccountMasterRow.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._AccountMasterRow.Entity = null;
    						previousValue.OrderBalanceRows.Remove(this);
    					}
    					this._AccountMasterRow.Entity = value;
    					if ((value != null))
    					{
    						value.OrderBalanceRows.Add(this);
    						this._SN = value.SN;
    						this._Mbrnu = value.Mbrnu;
    					}
    					else
    					{
    						this._SN = default(string);
    						this._Mbrnu = default(decimal);
    					}
    					this.SendPropertyChanged("AccountMasterRow");
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    	}
    	
    	[Table(Name="dbo.AccountMaster")]
    	public partial class AccountMasterRow : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _AcctID;
    		
    		private string _SN;
    		
    		private decimal _Mbrnu;
    		
    		private string _Frstnm;
    		
    		private string _Mdlinitl;
    		
    		private string _Lstnm;
    		
    		private string _Staddr;
    		
    		private string _AddrSuppl;
    		
    		private string _Twn;
    		
    		private string _State;
    		
    		private string _Zip10;
    		
    		private string _HmPhn;
    		
    		private string _SecPhn;
    		
    		private string _SecPhnExt;
    		
    		private string _PobPhn;
    		
    		private string _PobPhnExt;
    		
    		private string _Language;
    		
    		private decimal _HighBal;
    		
    		private System.DateTime _LstCdtDt;
    		
    		private decimal _LTV;
    		
    		private System.DateTime _NoDate;
    		
    		private int _MaxOpnMbrs;
    		
    		private string _SocSecNbr;
    		
    		private int _CumMbrs;
    		
    		private EntitySet<OrderBalanceRow> _OrderBalanceRows;
    		
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnRcdIDChanging(int value);
        partial void OnRcdIDChanged();
        partial void OnSNChanging(string value);
        partial void OnSNChanged();
        partial void OnMbrnuChanging(decimal value);
        partial void OnMbrnuChanged();
        partial void OnFrstnmChanging(string value);
        partial void OnFrstnmChanged();
        partial void OnMdlinitlChanging(string value);
        partial void OnMdlinitlChanged();
        partial void OnLstnmChanging(string value);
        partial void OnLstnmChanged();
        partial void OnStaddrChanging(string value);
        partial void OnStaddrChanged();
        partial void OnAddrSupplChanging(string value);
        partial void OnAddrSupplChanged();
        partial void OnTwnChanging(string value);
        partial void OnTwnChanged();
        partial void OnStateChanging(string value);
        partial void OnStateChanged();
        partial void OnZip10Changing(string value);
        partial void OnZip10Changed();
        partial void OnHmPhnChanging(string value);
        partial void OnHmPhnChanged();
        partial void OnSecPhnChanging(string value);
        partial void OnSecPhnChanged();
        partial void OnSecPhnExtChanging(string value);
        partial void OnSecPhnExtChanged();
        partial void OnPobPhnChanging(string value);
        partial void OnPobPhnChanged();
        partial void OnPobPhnExtChanging(string value);
        partial void OnPobPhnExtChanged();
        partial void OnLanguageChanging(string value);
        partial void OnLanguageChanged();
        partial void OnHighBalChanging(decimal value);
        partial void OnHighBalChanged();
        partial void OnLstCdtDtChanging(System.DateTime value);
        partial void OnLstCdtDtChanged();
        partial void OnLTVChanging(decimal value);
        partial void OnLTVChanged();
        partial void OnNoDateChanging(System.DateTime value);
        partial void OnNoDateChanged();
        partial void OnMaxOpnMbrsChanging(int value);
        partial void OnMaxOpnMbrsChanged();
        partial void OnSocSecNbrChanging(string value);
        partial void OnSocSecNbrChanged();
        partial void OnCumMbrsChanging(int value);
        partial void OnCumMbrsChanged();
        #endregion
    		
    		public AccountMasterRow()
    		{
    			this._OrderBalanceRows = new EntitySet<OrderBalanceRow>(new Action<OrderBalanceRow>(this.attach_OrderBalanceRows), new Action<OrderBalanceRow>(this.detach_OrderBalanceRows));
    			OnCreated();
    		}
    		
    		[Column(Storage="_AcctID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int RcdID
    		{
    			get
    			{
    				return this._AcctID;
    			}
    			set
    			{
    				if ((this._AcctID != value))
    				{
    					this.OnRcdIDChanging(value);
    					this.SendPropertyChanging();
    					this._AcctID = value;
    					this.SendPropertyChanged("RcdID");
    					this.OnRcdIDChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_SN", DbType="NChar(6) NOT NULL", CanBeNull=false)]
    		public string SN
    		{
    			get
    			{
    				return this._SN;
    			}
    			set
    			{
    				if ((this._SN != value))
    				{
    					this.OnSNChanging(value);
    					this.SendPropertyChanging();
    					this._SN = value;
    					this.SendPropertyChanged("SN");
    					this.OnSNChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Mbrnu", DbType="Decimal(5,0) NOT NULL")]
    		public decimal Mbrnu
    		{
    			get
    			{
    				return this._Mbrnu;
    			}
    			set
    			{
    				if ((this._Mbrnu != value))
    				{
    					this.OnMbrnuChanging(value);
    					this.SendPropertyChanging();
    					this._Mbrnu = value;
    					this.SendPropertyChanged("Mbrnu");
    					this.OnMbrnuChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Frstnm", DbType="NChar(20) NOT NULL", CanBeNull=false)]
    		public string Frstnm
    		{
    			get
    			{
    				return this._Frstnm;
    			}
    			set
    			{
    				if ((this._Frstnm != value))
    				{
    					this.OnFrstnmChanging(value);
    					this.SendPropertyChanging();
    					this._Frstnm = value;
    					this.SendPropertyChanged("Frstnm");
    					this.OnFrstnmChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Mdlinitl", DbType="NChar(5) NOT NULL", CanBeNull=false)]
    		public string Mdlinitl
    		{
    			get
    			{
    				return this._Mdlinitl;
    			}
    			set
    			{
    				if ((this._Mdlinitl != value))
    				{
    					this.OnMdlinitlChanging(value);
    					this.SendPropertyChanging();
    					this._Mdlinitl = value;
    					this.SendPropertyChanged("Mdlinitl");
    					this.OnMdlinitlChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Lstnm", DbType="NChar(30) NOT NULL", CanBeNull=false)]
    		public string Lstnm
    		{
    			get
    			{
    				return this._Lstnm;
    			}
    			set
    			{
    				if ((this._Lstnm != value))
    				{
    					this.OnLstnmChanging(value);
    					this.SendPropertyChanging();
    					this._Lstnm = value;
    					this.SendPropertyChanged("Lstnm");
    					this.OnLstnmChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Staddr", DbType="NChar(30) NOT NULL", CanBeNull=false)]
    		public string Staddr
    		{
    			get
    			{
    				return this._Staddr;
    			}
    			set
    			{
    				if ((this._Staddr != value))
    				{
    					this.OnStaddrChanging(value);
    					this.SendPropertyChanging();
    					this._Staddr = value;
    					this.SendPropertyChanged("Staddr");
    					this.OnStaddrChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_AddrSuppl", DbType="NChar(30) NOT NULL", CanBeNull=false)]
    		public string AddrSuppl
    		{
    			get
    			{
    				return this._AddrSuppl;
    			}
    			set
    			{
    				if ((this._AddrSuppl != value))
    				{
    					this.OnAddrSupplChanging(value);
    					this.SendPropertyChanging();
    					this._AddrSuppl = value;
    					this.SendPropertyChanged("AddrSuppl");
    					this.OnAddrSupplChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Twn", DbType="NChar(20) NOT NULL", CanBeNull=false)]
    		public string Twn
    		{
    			get
    			{
    				return this._Twn;
    			}
    			set
    			{
    				if ((this._Twn != value))
    				{
    					this.OnTwnChanging(value);
    					this.SendPropertyChanging();
    					this._Twn = value;
    					this.SendPropertyChanged("Twn");
    					this.OnTwnChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_State", DbType="NChar(2) NOT NULL", CanBeNull=false)]
    		public string State
    		{
    			get
    			{
    				return this._State;
    			}
    			set
    			{
    				if ((this._State != value))
    				{
    					this.OnStateChanging(value);
    					this.SendPropertyChanging();
    					this._State = value;
    					this.SendPropertyChanged("State");
    					this.OnStateChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Zip10", DbType="NChar(10) NOT NULL", CanBeNull=false)]
    		public string Zip10
    		{
    			get
    			{
    				return this._Zip10;
    			}
    			set
    			{
    				if ((this._Zip10 != value))
    				{
    					this.OnZip10Changing(value);
    					this.SendPropertyChanging();
    					this._Zip10 = value;
    					this.SendPropertyChanged("Zip10");
    					this.OnZip10Changed();
    				}
    			}
    		}
    		
    		[Column(Storage="_HmPhn", DbType="NChar(12) NOT NULL", CanBeNull=false)]
    		public string HmPhn
    		{
    			get
    			{
    				return this._HmPhn;
    			}
    			set
    			{
    				if ((this._HmPhn != value))
    				{
    					this.OnHmPhnChanging(value);
    					this.SendPropertyChanging();
    					this._HmPhn = value;
    					this.SendPropertyChanged("HmPhn");
    					this.OnHmPhnChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_SecPhn", DbType="NChar(12) NOT NULL", CanBeNull=false)]
    		public string SecPhn
    		{
    			get
    			{
    				return this._SecPhn;
    			}
    			set
    			{
    				if ((this._SecPhn != value))
    				{
    					this.OnSecPhnChanging(value);
    					this.SendPropertyChanging();
    					this._SecPhn = value;
    					this.SendPropertyChanged("SecPhn");
    					this.OnSecPhnChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_SecPhnExt", DbType="NChar(6) NOT NULL", CanBeNull=false)]
    		public string SecPhnExt
    		{
    			get
    			{
    				return this._SecPhnExt;
    			}
    			set
    			{
    				if ((this._SecPhnExt != value))
    				{
    					this.OnSecPhnExtChanging(value);
    					this.SendPropertyChanging();
    					this._SecPhnExt = value;
    					this.SendPropertyChanged("SecPhnExt");
    					this.OnSecPhnExtChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_PobPhn", DbType="NChar(12) NOT NULL", CanBeNull=false)]
    		public string PobPhn
    		{
    			get
    			{
    				return this._PobPhn;
    			}
    			set
    			{
    				if ((this._PobPhn != value))
    				{
    					this.OnPobPhnChanging(value);
    					this.SendPropertyChanging();
    					this._PobPhn = value;
    					this.SendPropertyChanged("PobPhn");
    					this.OnPobPhnChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_PobPhnExt", DbType="NChar(6) NOT NULL", CanBeNull=false)]
    		public string PobPhnExt
    		{
    			get
    			{
    				return this._PobPhnExt;
    			}
    			set
    			{
    				if ((this._PobPhnExt != value))
    				{
    					this.OnPobPhnExtChanging(value);
    					this.SendPropertyChanging();
    					this._PobPhnExt = value;
    					this.SendPropertyChanged("PobPhnExt");
    					this.OnPobPhnExtChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_Language", DbType="NChar(10) NOT NULL", CanBeNull=false)]
    		public string Language
    		{
    			get
    			{
    				return this._Language;
    			}
    			set
    			{
    				if ((this._Language != value))
    				{
    					this.OnLanguageChanging(value);
    					this.SendPropertyChanging();
    					this._Language = value;
    					this.SendPropertyChanged("Language");
    					this.OnLanguageChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_HighBal", DbType="Decimal(8,2) NOT NULL")]
    		public decimal HighBal
    		{
    			get
    			{
    				return this._HighBal;
    			}
    			set
    			{
    				if ((this._HighBal != value))
    				{
    					this.OnHighBalChanging(value);
    					this.SendPropertyChanging();
    					this._HighBal = value;
    					this.SendPropertyChanged("HighBal");
    					this.OnHighBalChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_LstCdtDt", DbType="Date NOT NULL")]
    		public System.DateTime LstCdtDt
    		{
    			get
    			{
    				return this._LstCdtDt;
    			}
    			set
    			{
    				if ((this._LstCdtDt != value))
    				{
    					this.OnLstCdtDtChanging(value);
    					this.SendPropertyChanging();
    					this._LstCdtDt = value;
    					this.SendPropertyChanged("LstCdtDt");
    					this.OnLstCdtDtChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_LTV", DbType="Decimal(9,2) NOT NULL")]
    		public decimal LTV
    		{
    			get
    			{
    				return this._LTV;
    			}
    			set
    			{
    				if ((this._LTV != value))
    				{
    					this.OnLTVChanging(value);
    					this.SendPropertyChanging();
    					this._LTV = value;
    					this.SendPropertyChanged("LTV");
    					this.OnLTVChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_NoDate", DbType="Date NOT NULL")]
    		public System.DateTime NoDate
    		{
    			get
    			{
    				return this._NoDate;
    			}
    			set
    			{
    				if ((this._NoDate != value))
    				{
    					this.OnNoDateChanging(value);
    					this.SendPropertyChanging();
    					this._NoDate = value;
    					this.SendPropertyChanged("NoDate");
    					this.OnNoDateChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_MaxOpnMbrs", DbType="Int NOT NULL")]
    		public int MaxOpnMbrs
    		{
    			get
    			{
    				return this._MaxOpnMbrs;
    			}
    			set
    			{
    				if ((this._MaxOpnMbrs != value))
    				{
    					this.OnMaxOpnMbrsChanging(value);
    					this.SendPropertyChanging();
    					this._MaxOpnMbrs = value;
    					this.SendPropertyChanged("MaxOpnMbrs");
    					this.OnMaxOpnMbrsChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_SocSecNbr", DbType="NChar(11) NOT NULL", CanBeNull=false)]
    		public string SocSecNbr
    		{
    			get
    			{
    				return this._SocSecNbr;
    			}
    			set
    			{
    				if ((this._SocSecNbr != value))
    				{
    					this.OnSocSecNbrChanging(value);
    					this.SendPropertyChanging();
    					this._SocSecNbr = value;
    					this.SendPropertyChanged("SocSecNbr");
    					this.OnSocSecNbrChanged();
    				}
    			}
    		}
    		
    		[Column(Storage="_CumMbrs", DbType="Int NOT NULL")]
    		public int CumMbrs
    		{
    			get
    			{
    				return this._CumMbrs;
    			}
    			set
    			{
    				if ((this._CumMbrs != value))
    				{
    					this.OnCumMbrsChanging(value);
    					this.SendPropertyChanging();
    					this._CumMbrs = value;
    					this.SendPropertyChanged("CumMbrs");
    					this.OnCumMbrsChanged();
    				}
    			}
    		}
    		
    		[Association(Name="AccountMasterRow_OrderBalanceRow", Storage="_OrderBalanceRows", ThisKey="SN,Mbrnu", OtherKey="SN,Mbrnu")]
    		public EntitySet<OrderBalanceRow> OrderBalanceRows
    		{
    			get
    			{
    				return this._OrderBalanceRows;
    			}
    			set
    			{
    				this._OrderBalanceRows.Assign(value);
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    		
    		private void attach_OrderBalanceRows(OrderBalanceRow entity)
    		{
    			this.SendPropertyChanging();
    			entity.AccountMasterRow = this;
    		}
    		
    		private void detach_OrderBalanceRows(OrderBalanceRow entity)
    		{
    			this.SendPropertyChanging();
    			entity.AccountMasterRow = null;
    		}
    	}
    }
    #pragma warning restore 1591
    
    Wednesday, May 27, 2009 9:27 PM
  • The problem here is:

    	[Association(Name="AccountMasterRow_OrderBalanceRow",
          Storage="_AccountMasterRow", ThisKey="SN,Mbrnu", OtherKey="SN,Mbrnu", IsForeignKey=true)]

    And that the primary key for the AccountMasterRow class is not actually SN, Mbrnu.

    This has been fixed in .NET 4.0 and a hotfix is available for 3.5 SP1 that you can obtain via CSS.

    [)amien
    • Marked as answer by Steve Richter Thursday, May 28, 2009 3:01 PM
    Thursday, May 28, 2009 4:57 AM
    Moderator
  • I am running 3.5 SP1.  What is CSS and how do I know which hotfix to apply?

    I really appreciate the help.


    Thursday, May 28, 2009 3:03 PM
  • We had a similar problem, caused by using non-integer keys. Details and hotfix number are here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351358
    Wednesday, September 16, 2009 5:59 PM