Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fca2efa

Browse files
Nitish KaushikNitish Kaushik
Nitish Kaushik
authored and
Nitish Kaushik
committed
Added db context class and configured ef core
1 parent 96d3691 commit fca2efa

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace Webgentle.BookStore.Data
8+
{
9+
public class BookStoreContext : DbContext
10+
{
11+
public BookStoreContext(DbContextOptions<BookStoreContext> options)
12+
: base(options)
13+
{
14+
15+
}
16+
17+
public DbSet<Books> Books { get; set; }
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Webgentle.BookStore.Data
7+
{
8+
public class Books
9+
{
10+
public int Id { get; set; }
11+
public string Title { get; set; }
12+
public string Author { get; set; }
13+
public string Description { get; set; }
14+
public string Category { get; set; }
15+
public string Language { get; set; }
16+
public int TotalPages { get; set; }
17+
}
18+
}

‎Webgentle.BookStore/Webgentle.BookStore/Startup.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
using Microsoft.AspNetCore.Builder;
77
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.AspNetCore.Http;
9+
using Microsoft.EntityFrameworkCore;
910
using Microsoft.Extensions.DependencyInjection;
1011
using Microsoft.Extensions.FileProviders;
1112
using Microsoft.Extensions.Hosting;
13+
using Webgentle.BookStore.Data;
1214

1315
namespace Webgentle.BookStore
1416
{
@@ -18,6 +20,9 @@ public class Startup
1820
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
1921
public void ConfigureServices(IServiceCollection services)
2022
{
23+
services.AddDbContext<BookStoreContext>(
24+
options => options.UseSqlServer("Server=.;Database=BookStore;Integrated Security=True;"));
25+
2126
services.AddControllersWithViews();
2227
#if DEBUG
2328
services.AddRazorPages().AddRazorRuntimeCompilation();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /