public static void AddCourseWithAuthorId() { using (var context = new PlutoContext()) { var courseWithAuthorId = new Course { Name = "Course with author id", Description = "Descrpition", FullPrice = 19.95f, Level = Course.CourseLevel.Beginner, AuthorId = 1 }; context.Add(courseWithAuthorId); context.SaveChanges(); } }
public static void AddCourseWithAuthorObject() { using (var context = new PlutoContext()) { var author = context.Authors.Single(q => q.Id == 1); var courseWithAuthorObject = new Course { Name = "Course with author object", Description = "Descrpition", FullPrice = 19.95f, Level = Course.CourseLevel.Beginner, Author = author }; context.Add(courseWithAuthorObject); context.SaveChanges(); } }
public void Create(T entity) { _context.Add(entity); // Save(); }