c# - Is this use of Create() right in an Entity Framework context? -
when creating object persisted database, , using create()
method purpose, following snippets same?
snippet 1:
client client = new client(); client.name = "jonh doe"; database.clients.add(client); database.savechanges();
snippet 2:
var client = database.clients.create(); client.name = "jonh doe"; database.savechanges();
according http://msdn.microsoft.com/en-us/library/gg679504(v=vs.113).aspx don't.
"note instance not added or attached set"
so second snippet should be
var client = database.clients.create(); client.name = "jonh doe"; database.clients.add(client); database.savechanges();
Comments
Post a Comment