I cant solve this error when I add a new row my MVC DB project even though I see people have solved this before with Linq. I am not using Linq but EF. I have a MVC project, VS 2010 and connected to a sql 2008 via designer
1)created internet project 2) right click on models - > add new item-> ado entity data model and select the remote DB.
3)create controller 4) run project and see the screen to create new row. I do this and get this error after I add 2 rows. I pre-create the table and have the PK defined in sql server 2008 as an Int
Server Error in '/' Application. Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.
I didnt write any code so so I am not sure what else I need to say
[Serializable()] [DataContractAttribute(IsReference=true)] public partial class video : EntityObject { #region Factory Method
/// <summary>
/// Create a new video object.
/// </summary>
/// <param name="id">Initial value of the ID property.</param>
public static video Createvideo(global::System.Int32 id)
{
video video = new video();
video.ID = id;
return video;
}
#endregion
#region Primitive Properties
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Int32 ID
{
get
{
return _ID;
}
set
{
if (_ID != value)
{
OnIDChanging(value);
ReportPropertyChanging("ID");
_ID = StructuralObject.SetValidValue(value);
ReportPropertyChanged("ID");
OnIDChanged();
}
}
}
private global::System.Int32 _ID;
partial void OnIDChanging(global::System.Int32 value);
partial void OnIDChanged();
/// <summary>
/// No Metadata Documentation available.
/// </summary>