-1

Having problem with inserting a model to database with EF in a MVC application.

Im receiving following error when callning dbContext.SaveChanges() :

[DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.]

Any clue what this can be about?

Its strange because sometimes it works to make one insert but if i make another immediately after it crashes.

And sometimes it crashes on first insert.

MikeAlike234
  • 759
  • 2
  • 12
  • 29

2 Answers2

0

You can check the accepted answer in this post: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

PS: Please remove error message details as it's of no use and it can expose private information.

Community
  • 1
  • 1
Ferit Buyukkececi
  • 2,665
  • 2
  • 20
  • 23
0

More than likely you have some property on the entity that is not nullable. Most of the time when I get this error, that's the culprit. Set a watch on the 'EntityValidationErrors' property, then in the debugger expand into this property and you will see the exact message that is being thrown.