Last post Oct 20, 2009 09:59 PM by stuzzo
Oct 17, 2009 05:38 PM|stuzzo|LINK
Hi to all.
I know that this topic has already been tackled but I can't solve my problem.
I'm new on MVC application and I'm just try to build my first application following this tutorial
When I try to add a new row, i've got this message "Cannot insert explicit value for identity column in table 'Movies' when IDENTITY_INSERT is set to OFF."
I checked the code and I insert the Bind(Exclude="ID") and set the "ID" column to identity. I try also to launch a query like SET Movies IDENTITY_INSERT ON, but nothing.
Thanks to all in advance!
Oct 19, 2009 06:49 PM|stuzzo|LINK
Anyone can help me?
Oct 19, 2009 07:10 PM|gerrylowry|LINK
Silly question (mistake I've made myself):
if you go to the table designer, is your field set as the Primary Key?
as, are the identify properties set? (I'm guessing they are).
Oct 19, 2009 07:56 PM|stuzzo|LINK
Thanks for the answer :) !
I checked....The id field is primary key and on the tab Identity Specification I set Identity_Specification=Yes, Identity increment=1, Identity seed = 1.
Should I check some other properties ?
Oct 19, 2009 09:36 PM|ricka6|LINK
For EF you need to set StoreGeneratedPattern="Computed"
for L2S IsDbGenerated="true"
Oct 19, 2009 09:38 PM|ricka6|LINK
I would also look at something much more current.
Oct 19, 2009 09:41 PM|gerrylowry|LINK
it would be best if you could post your code and your .aspx page.
also, information about your environment (include service pack level SP1, SP2, ...:
o/s version; visual studio version; .Net framework versionp; browser version;
are you testing with ASP.NET Development Server?; et cetera
also, more of the stack trace and error messages you get ...
if it's unhandled exception, what type?
best we do not have to guess ... example, you do not explicitly say c#
but likely you are using c# because you are working only the -cs
version of tutorial 16.
PLEASE NOTE: you may want to try this tutorial instead
to see whether you can get it working ... it's a small tutorial
and if all goes well, should take you less than a hour or two
(it claims only 15 minutes):
the movie database tutorial (uses LINQ to Entities):
Creating a Movie Database Application with ASP.NET MVC (C#) http://www.asp.net/learn/mvc/tutorial-21-cs.aspx
you may find these notes useful:
the above notes are also quite relevant to the vb.net version too
because generally the only difference between the c# and vb version is the language.
Oct 20, 2009 09:59 PM|stuzzo|LINK
Thanks for all replies.
I checked all the properties, but nothing. So I tried to create a new project following the same tutorial with Entity Framework, c# language and now it works :).
Thanks for the links. I'll read them.