Have a look at this: https://stackoverflow.com/a/5338384/171703 – entity framework might be assuming that your CategoryId field is an identity and therefore passing null to the database expecting it to fill it for you.
Have a look at this: https://stackoverflow.com/a/5338384/171703 – entity framework might be assuming that your CategoryId field is an identity and therefore passing null to the database expecting it to fill it for you.