File tree Expand file tree Collapse file tree 12 files changed +720
-0
lines changed
Expand file tree Collapse file tree 12 files changed +720
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net5.0</TargetFramework >
6+ </PropertyGroup >
7+
8+ <ItemGroup >
9+ <PackageReference Include =" Microsoft.EntityFrameworkCore" Version =" 5.0.9" />
10+ <PackageReference Include =" Microsoft.EntityFrameworkCore.SqlServer" Version =" 5.0.9" />
11+ </ItemGroup >
12+
13+ </Project >
Original file line number Diff line number Diff line change 1+ using Blog . Models ;
2+ using Microsoft . EntityFrameworkCore ;
3+
4+ namespace Blog . Data
5+ {
6+ public class BlogDataContext : DbContext
7+ {
8+ public DbSet < Category > Categories { get ; set ; }
9+ public DbSet < Post > Posts { get ; set ; }
10+ // public DbSet<PostTag> PostTags { get; set; }
11+ public DbSet < Role > Roles { get ; set ; }
12+ public DbSet < Tag > Tags { get ; set ; }
13+ public DbSet < User > Users { get ; set ; }
14+ // public DbSet<UserRole> UserRoles { get; set; }
15+
16+ protected override void OnConfiguring ( DbContextOptionsBuilder options )
17+ => options . UseSqlServer ( "Server=localhost,1433;Database=Blog;User ID=sa;Password=1q2w3e4r@#$" ) ;
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ namespace Blog . Models
2+ {
3+ public class Category
4+ {
5+ public int Id { get ; set ; }
6+ public string Name { get ; set ; }
7+ public string Slug { get ; set ; }
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace Blog . Models
4+ {
5+ public class Post
6+ {
7+ public int Id { get ; set ; }
8+ public int CategoryId { get ; set ; }
9+ public int AuthorId { get ; set ; }
10+ public string Title { get ; set ; }
11+ public string Summary { get ; set ; }
12+ public string Body { get ; set ; }
13+ public string Slug { get ; set ; }
14+ public DateTime CreateDate { get ; set ; }
15+ public DateTime LastUpdateDate { get ; set ; }
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ namespace Blog . Models
2+ {
3+ public class PostTag
4+ {
5+ public int PostId { get ; set ; }
6+ public int TagId { get ; set ; }
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ namespace Blog . Models
2+ {
3+ public class Role
4+ {
5+ public int Id { get ; set ; }
6+ public string Name { get ; set ; }
7+ public string Slug { get ; set ; }
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ using System . ComponentModel . DataAnnotations ;
2+ using System . ComponentModel . DataAnnotations . Schema ;
3+
4+ namespace Blog . Models
5+ {
6+ [ Table ( "Tag" ) ]
7+ public class Tag
8+ {
9+ [ Key ]
10+ public int Id { get ; set ; }
11+ public string Name { get ; set ; }
12+ public string Slug { get ; set ; }
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ namespace Blog . Models
2+ {
3+ public class User
4+ {
5+ public int Id { get ; set ; }
6+ public string Name { get ; set ; }
7+ public string Email { get ; set ; }
8+ public string PasswordHash { get ; set ; }
9+ public string Image { get ; set ; }
10+ public string Slug { get ; set ; }
11+ public string Bio { get ; set ; }
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ namespace Blog . Models
2+ {
3+ public class UserRole
4+ {
5+ public int UserId { get ; set ; }
6+ public int RoleId { get ; set ; }
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments