for using or load database information in layout, we can use inject in layout.html.
@inject ProjectName.Data.ApplicationDbContext contex
@{
var posts = contex.Posts.ToList();
}
@foreach(var post in posts)
{
<h4> @post.Title </h4>
}

for using or load database information in layout, we can use inject in layout.html.
@inject ProjectName.Data.ApplicationDbContext contex
@{
var posts = contex.Posts.ToList();
}
@foreach(var post in posts)
{
<h4> @post.Title </h4>
}