Solution ----


Title
Get Record Id after Insert in database with Entity Framework (EF)
Titre
Obtenir l'Id d'un enregistrement après insertion dans la base avec Entity Framework (EF)
Título
Url
Language:
C#
Framework
Entity Framework (EF)
SOLUTION:

 
Author author = new Author() { FirstName = "fname", LastName = "lname" };
int authorId = 0;
using (var context = new ApplicationDbContext())
  {
    context.Authors.Add(author);
    context.SaveChanges();
    authorId = author.Id;
  }

;
Source
InforMaths
Free
Rate
Date
2016/12/27

Back to List