Skip to content

Instantly share code, notes, and snippets.

View marcfabregatb's full-sized avatar

Marc Fabregat marcfabregatb

View GitHub Profile
public async Task<IActionResult> Edit(string id)
{
if (string.IsNullOrWhiteSpace(id))
{
return NotFound();
}
var blogEntry = await _context.BlogEntries.Include(x => x.Categories).FirstOrDefaultAsync(x => x.Id == id);
if (blogEntry == null)
@marcfabregatb
marcfabregatb / BlogEntry.cs
Last active August 8, 2021 19:08
Entity Framework core 5 - Many to Many Relationship
public class BlogEntry
{
[Key]
public string Id { get; set; }
[Required]
[MaxLength(200)]
public string Title { get; set; }
[Required]
public string Text { get; set; }