Saturday, April 2, 2011

Problem in mapping fragments starting at line nnn:All the key properties (xxxx.column) of the EntitySet xxxx must be mapped to all the key properties

Problem:

Error 3003: Problem in mapping fragments starting at line 257:All the key properties (table.column) of the EntitySet table must be mapped to all the key properties (table.column, table.column) of table table.


Solution:

Select the column giving you problems, hit F4 for properties, and change Nullable from (None) to False.




















Wednesday, March 30, 2011

Index (zero based) must be greater than or equal to zero and less than the size of the argument list

Problem:
System.FormatException was unhandled by user code
  Message=Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
  Source=mscorlib
  StackTrace:
       at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
       at System.String.Format(IFormatProvider provider, String format, Object[] args)
       at System.String.Format(String format, Object arg0)
       at MultiThreadedDbSeeder.Program.<Main>b__0(Int32 i) in C:\xxxx\Program.cs:line 22
       at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.b__c()
  InnerException:

Offending Line:
SqlCommand cmd = new SqlCommand(string.Format(@"insert into table_1 (vch_value) values('{1}')", "the value of i is " + i));

Solution:
Don’t forget that string.Format uses a zero based index.
Fixed Code:
SqlCommand cmd = new SqlCommand(string.Format(@"insert into table_1 (vch_value) values('{0}')", "the value of i is " + i));

Tuesday, March 29, 2011

The project file has been moved, renamed or is not on your computer

Solution:
1) Close the solution you have open.
2) In the project folder which is giving you problems, find the .suo file and delete it.
3) Reopen your solution and add the project back.