3
I am trying to study EF with Code First. I am getting this exception on SaveChanges()
An unhandled Exception of type System.Data.Entity.Infrastructure.Dbupdateexception occurred in Entityframework.dll
Additional information: An error occurred while updating the Entries. See the Inner Exception for Details.
Another problem would be when I try to create another class to serve as a table, I get an exception called InvalidOperationException
follow the stack trace
An unhandled Exception of type 'System.Invalidoperationexception' occurred in Entityframework.dll
Additional information: The model backing the 'Schoolcontext' context has changed Since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/? Linkid=238269).
I’m managing to create the database, but I’m not able to insert data in it.
– Iago Frota
Your question already has an answer here, but I marked the wrong duplicate. See if it fits you.
– Leonel Sanches da Silva
Funny! I was studying here : [http://www.entityframeworktutorial.net/code-first/entity-framework-code-first.aspx]. I commented some
Properties
classStudent
and spun!– Iago Frota
@Ciganomorrisonmendez It’s a very interesting approach!! I loved your answer. But I have another problem, when I try to create another class I get in context
ctx.Professores.Add(prof)
I receive an exception An unhandled Exception of type 'System.Invalidoperationexception' occurred in Entityframework.dll Additional information: The model backing the 'Schoolcontext' context has changed Since the database was created. Consider using Code First Migrations to update the database ([http://go.microsoft.com/fwlink/? Linkid=238269]).– Iago Frota
Edit your answer by placing this new error (do not delete the previous text) that I answer to you.
– Leonel Sanches da Silva