Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27469

Entity Framework

$
0
0
I've instantiated a new Users entity and attached an new Avatars entity to it. The primary and foreign key in the Avatar table is UserID and the primary key in the user table is UserID.

When I try to save the Users entity object I get an error message saying that the UserID column in the Avatar table cannot be Null. The entity framework, apparently, is not creating a new UserID in the Users table and Avatars table in the same save statement.

The code works if i save the users object first and then retrieve the userID and then save the avatar seperately but this seems quite long winded to me. Is there any way to make these changes in one go?

Thanks

Viewing all articles
Browse latest Browse all 27469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>