begin scaffolding data access layer

This commit is contained in:
Aaron Po
2025-10-28 18:28:30 -04:00
parent 2f0bfd90b2
commit 738c055bf7
18 changed files with 1071 additions and 3 deletions

428
.gitignore vendored Normal file
View File

@@ -0,0 +1,428 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
*.env
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Dd]ebug/x64/
[Dd]ebugPublic/x64/
[Rr]elease/x64/
[Rr]eleases/x64/
bin/x64/
obj/x64/
[Dd]ebug/x86/
[Dd]ebugPublic/x86/
[Rr]elease/x86/
[Rr]eleases/x86/
bin/x86/
obj/x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Aa][Rr][Mm]64[Ee][Cc]/
bld/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Build results on 'Bin' directories
**/[Bb]in/*
# Uncomment if you have tasks that rely on *.refresh files to move binaries
# (https://github.com/github/gitignore/pull/3736)
#!**/[Bb]in/*.refresh
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.trx
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Approval Tests result files
*.received.*
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.idb
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
**/.paket/paket.exe
paket-files/
# FAKE - F# Make
**/.fake/
# CodeRush personal settings
**/.cr/personal
# Python Tools for Visual Studio (PTVS)
**/__pycache__/
*.pyc
# Cake - Uncomment if you are using it
#tools/**
#!tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
MSBuild_Logs/
# AWS SAM Build and Temporary Artifacts folder
.aws-sam
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
**/.mfractor/
# Local History for Visual Studio
**/.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
**/.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class BeerPost
{
public Guid BeerPostID { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public decimal ABV { get; set; }
public int IBU { get; set; }
public Guid PostedByID { get; set; }
public Guid BeerStyleID { get; set; }
public Guid BrewedByID { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public virtual ICollection<BeerPostPhoto> BeerPostPhotos { get; set; } = new List<BeerPostPhoto>();
public virtual BeerStyle BeerStyle { get; set; } = null!;
public virtual BreweryPost BrewedBy { get; set; } = null!;
public virtual UserAccount PostedBy { get; set; } = null!;
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class BeerPostPhoto
{
public Guid BeerPostPhotoID { get; set; }
public Guid BeerPostID { get; set; }
public Guid PhotoID { get; set; }
public DateTime LinkedAt { get; set; }
public virtual BeerPost BeerPost { get; set; } = null!;
public virtual Photo Photo { get; set; } = null!;
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class BeerStyle
{
public Guid BeerStyleID { get; set; }
public string StyleName { get; set; } = null!;
public string? Description { get; set; }
public virtual ICollection<BeerPost> BeerPosts { get; set; } = new List<BeerPost>();
}

View File

@@ -0,0 +1,300 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace DataAccessLayer;
public partial class BiergartenContext : DbContext
{
public BiergartenContext()
{
}
public BiergartenContext(DbContextOptions<BiergartenContext> options)
: base(options)
{
}
public virtual DbSet<BeerPost> BeerPosts { get; set; }
public virtual DbSet<BeerPostPhoto> BeerPostPhotos { get; set; }
public virtual DbSet<BeerStyle> BeerStyles { get; set; }
public virtual DbSet<BreweryPost> BreweryPosts { get; set; }
public virtual DbSet<BreweryPostPhoto> BreweryPostPhotos { get; set; }
public virtual DbSet<Comment> Comments { get; set; }
public virtual DbSet<Photo> Photos { get; set; }
public virtual DbSet<UserAccount> UserAccounts { get; set; }
public virtual DbSet<UserAvatar> UserAvatars { get; set; }
public virtual DbSet<UserCredential> UserCredentials { get; set; }
public virtual DbSet<UserFollow> UserFollows { get; set; }
public virtual DbSet<UserVerification> UserVerifications { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseSqlServer("Server=(localdb)\\ProjectModels;Database=Biergarten;Trusted_Connection=True;");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<BeerPost>(entity =>
{
entity.ToTable("BeerPost");
entity.HasIndex(e => e.BeerStyleID, "IX_BeerPost_BeerStyle");
entity.HasIndex(e => e.BrewedByID, "IX_BeerPost_BrewedBy");
entity.HasIndex(e => e.PostedByID, "IX_BeerPost_PostedBy");
entity.Property(e => e.BeerPostID).HasDefaultValueSql("(newid())");
entity.Property(e => e.ABV).HasColumnType("decimal(4, 2)");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.Property(e => e.Name).HasMaxLength(100);
entity.Property(e => e.UpdatedAt).HasColumnType("datetime");
entity.HasOne(d => d.BeerStyle).WithMany(p => p.BeerPosts)
.HasForeignKey(d => d.BeerStyleID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_BeerPost_BeerStyle");
entity.HasOne(d => d.BrewedBy).WithMany(p => p.BeerPosts)
.HasForeignKey(d => d.BrewedByID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_BeerPost_Brewery");
entity.HasOne(d => d.PostedBy).WithMany(p => p.BeerPosts)
.HasForeignKey(d => d.PostedByID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_BeerPost_PostedBy");
});
modelBuilder.Entity<BeerPostPhoto>(entity =>
{
entity.ToTable("BeerPostPhoto");
entity.HasIndex(e => new { e.BeerPostID, e.PhotoID }, "IX_BeerPostPhoto_BeerPost_Photo");
entity.HasIndex(e => new { e.PhotoID, e.BeerPostID }, "IX_BeerPostPhoto_Photo_BeerPost");
entity.Property(e => e.BeerPostPhotoID).HasDefaultValueSql("(newid())");
entity.Property(e => e.LinkedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.BeerPost).WithMany(p => p.BeerPostPhotos)
.HasForeignKey(d => d.BeerPostID)
.HasConstraintName("FK_BeerPostPhoto_BeerPost");
entity.HasOne(d => d.Photo).WithMany(p => p.BeerPostPhotos)
.HasForeignKey(d => d.PhotoID)
.HasConstraintName("FK_BeerPostPhoto_Photo");
});
modelBuilder.Entity<BeerStyle>(entity =>
{
entity.ToTable("BeerStyle");
entity.HasIndex(e => e.StyleName, "AK_BeerStyle_StyleName").IsUnique();
entity.Property(e => e.BeerStyleID).HasDefaultValueSql("(newid())");
entity.Property(e => e.StyleName).HasMaxLength(100);
});
modelBuilder.Entity<BreweryPost>(entity =>
{
entity.ToTable("BreweryPost");
entity.HasIndex(e => e.PostedByID, "IX_BreweryPost_PostedByID");
entity.Property(e => e.BreweryPostID).HasDefaultValueSql("(newid())");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.Property(e => e.Description).HasMaxLength(512);
entity.Property(e => e.UpdatedAt).HasColumnType("datetime");
entity.HasOne(d => d.PostedBy).WithMany(p => p.BreweryPosts)
.HasForeignKey(d => d.PostedByID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_BreweryPost_UserAccount");
});
modelBuilder.Entity<BreweryPostPhoto>(entity =>
{
entity.ToTable("BreweryPostPhoto");
entity.HasIndex(e => new { e.BreweryPostID, e.PhotoID }, "IX_BreweryPostPhoto_BreweryPost_Photo");
entity.HasIndex(e => new { e.PhotoID, e.BreweryPostID }, "IX_BreweryPostPhoto_Photo_BreweryPost");
entity.Property(e => e.BreweryPostPhotoID).HasDefaultValueSql("(newid())");
entity.Property(e => e.LinkedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.BreweryPost).WithMany(p => p.BreweryPostPhotos)
.HasForeignKey(d => d.BreweryPostID)
.HasConstraintName("FK_BreweryPostPhoto_BreweryPost");
entity.HasOne(d => d.Photo).WithMany(p => p.BreweryPostPhotos)
.HasForeignKey(d => d.PhotoID)
.HasConstraintName("FK_BreweryPostPhoto_Photo");
});
modelBuilder.Entity<Comment>(entity =>
{
entity.HasKey(e => e.CommentID).HasName("PK_CommentID");
entity.ToTable("Comment");
entity.HasIndex(e => e.PostedByID, "IX_Comment_PostedByID");
entity.Property(e => e.CommentID).HasDefaultValueSql("(newid())");
entity.Property(e => e.CommentText).HasMaxLength(512);
entity.HasOne(d => d.PostedBy).WithMany(p => p.Comments)
.HasForeignKey(d => d.PostedByID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_PostedByID");
});
modelBuilder.Entity<Photo>(entity =>
{
entity.ToTable("Photo");
entity.HasIndex(e => e.UploadedByID, "IX_Photo_UploadedByID");
entity.Property(e => e.PhotoID).HasDefaultValueSql("(newid())");
entity.Property(e => e.Hyperlink).HasMaxLength(256);
entity.Property(e => e.UploadedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.UploadedBy).WithMany(p => p.Photos)
.HasForeignKey(d => d.UploadedByID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Photo_UploadedBy");
});
modelBuilder.Entity<UserAccount>(entity =>
{
entity.ToTable("UserAccount");
entity.HasIndex(e => e.Email, "AK_Email").IsUnique();
entity.HasIndex(e => e.Username, "AK_Username").IsUnique();
entity.Property(e => e.UserAccountID).HasDefaultValueSql("(newid())");
entity.Property(e => e.CreatedAt).HasColumnType("datetime");
entity.Property(e => e.DateOfBirth).HasColumnType("datetime");
entity.Property(e => e.Email)
.HasMaxLength(128)
.IsUnicode(false);
entity.Property(e => e.FirstName).HasMaxLength(128);
entity.Property(e => e.LastName).HasMaxLength(128);
entity.Property(e => e.UpdatedAt).HasColumnType("datetime");
entity.Property(e => e.Username)
.HasMaxLength(64)
.IsUnicode(false);
});
modelBuilder.Entity<UserAvatar>(entity =>
{
entity.ToTable("UserAvatar");
entity.HasIndex(e => e.UserAccountID, "AK_UserAvatar_UserAccountID").IsUnique();
entity.HasIndex(e => e.UserAccountID, "IX_UserAvatar_UserAccount");
entity.Property(e => e.UserAvatarID).HasDefaultValueSql("(newid())");
entity.HasOne(d => d.Photo).WithMany(p => p.UserAvatars)
.HasForeignKey(d => d.PhotoID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_UserAvatar_PhotoID");
entity.HasOne(d => d.UserAccount).WithOne(p => p.UserAvatar)
.HasForeignKey<UserAvatar>(d => d.UserAccountID)
.HasConstraintName("FK_UserAvatar_UserAccount");
});
modelBuilder.Entity<UserCredential>(entity =>
{
entity.ToTable("UserCredential");
entity.HasIndex(e => e.UserAccountID, "AK_UserCredential_UserAccountID").IsUnique();
entity.HasIndex(e => e.UserAccountID, "IX_UserCredential_UserAccount");
entity.Property(e => e.UserCredentialID).HasDefaultValueSql("(newid())");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.Property(e => e.Expiry)
.HasDefaultValueSql("(dateadd(day,(90),getdate()))")
.HasColumnType("datetime");
entity.Property(e => e.Hash).HasMaxLength(100);
entity.HasOne(d => d.UserAccount).WithOne(p => p.UserCredential)
.HasForeignKey<UserCredential>(d => d.UserAccountID)
.HasConstraintName("FK_UserCredential_UserAccount");
});
modelBuilder.Entity<UserFollow>(entity =>
{
entity.ToTable("UserFollow");
entity.HasIndex(e => new { e.FollowingID, e.UserAccountID }, "IX_UserFollow_FollowingID_UserAccount");
entity.HasIndex(e => new { e.UserAccountID, e.FollowingID }, "IX_UserFollow_UserAccount_FollowingID");
entity.Property(e => e.UserFollowID).HasDefaultValueSql("(newid())");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.Following).WithMany(p => p.UserFollowFollowings)
.HasForeignKey(d => d.FollowingID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_UserFollow_UserAccountFollowing");
entity.HasOne(d => d.UserAccount).WithMany(p => p.UserFollowUserAccounts)
.HasForeignKey(d => d.UserAccountID)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_UserFollow_UserAccount");
});
modelBuilder.Entity<UserVerification>(entity =>
{
entity.ToTable("UserVerification");
entity.HasIndex(e => e.UserAccountID, "AK_UserVerification_UserAccountID").IsUnique();
entity.HasIndex(e => e.UserAccountID, "IX_UserVerification_UserAccount");
entity.Property(e => e.UserVerificationID).HasDefaultValueSql("(newid())");
entity.Property(e => e.VerificationDateTime)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.UserAccount).WithOne(p => p.UserVerification)
.HasForeignKey<UserVerification>(d => d.UserAccountID)
.HasConstraintName("FK_UserVerification_UserAccount");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class BreweryPost
{
public Guid BreweryPostID { get; set; }
public Guid PostedByID { get; set; }
public string Description { get; set; } = null!;
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public virtual ICollection<BeerPost> BeerPosts { get; set; } = new List<BeerPost>();
public virtual ICollection<BreweryPostPhoto> BreweryPostPhotos { get; set; } = new List<BreweryPostPhoto>();
public virtual UserAccount PostedBy { get; set; } = null!;
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class BreweryPostPhoto
{
public Guid BreweryPostPhotoID { get; set; }
public Guid BreweryPostID { get; set; }
public Guid PhotoID { get; set; }
public DateTime LinkedAt { get; set; }
public virtual BreweryPost BreweryPost { get; set; } = null!;
public virtual Photo Photo { get; set; } = null!;
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class Comment
{
public Guid CommentID { get; set; }
public string? CommentText { get; set; }
public Guid PostedByID { get; set; }
public virtual UserAccount PostedBy { get; set; } = null!;
}

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>DataAccessLayer</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

23
DataAccessLayer/Photo.cs Normal file
View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class Photo
{
public Guid PhotoID { get; set; }
public string? Hyperlink { get; set; }
public Guid UploadedByID { get; set; }
public DateTime UploadedAt { get; set; }
public virtual ICollection<BeerPostPhoto> BeerPostPhotos { get; set; } = new List<BeerPostPhoto>();
public virtual ICollection<BreweryPostPhoto> BreweryPostPhotos { get; set; } = new List<BreweryPostPhoto>();
public virtual UserAccount UploadedBy { get; set; } = null!;
public virtual ICollection<UserAvatar> UserAvatars { get; set; } = new List<UserAvatar>();
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class UserAccount
{
public Guid UserAccountID { get; set; }
public string Username { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string LastName { get; set; } = null!;
public string Email { get; set; } = null!;
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public DateTime DateOfBirth { get; set; }
public virtual ICollection<BeerPost> BeerPosts { get; set; } = new List<BeerPost>();
public virtual ICollection<BreweryPost> BreweryPosts { get; set; } = new List<BreweryPost>();
public virtual ICollection<Comment> Comments { get; set; } = new List<Comment>();
public virtual ICollection<Photo> Photos { get; set; } = new List<Photo>();
public virtual UserAvatar? UserAvatar { get; set; }
public virtual UserCredential? UserCredential { get; set; }
public virtual ICollection<UserFollow> UserFollowFollowings { get; set; } = new List<UserFollow>();
public virtual ICollection<UserFollow> UserFollowUserAccounts { get; set; } = new List<UserFollow>();
public virtual UserVerification? UserVerification { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class UserAvatar
{
public Guid UserAvatarID { get; set; }
public Guid UserAccountID { get; set; }
public Guid PhotoID { get; set; }
public virtual Photo Photo { get; set; } = null!;
public virtual UserAccount UserAccount { get; set; } = null!;
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class UserCredential
{
public Guid UserCredentialID { get; set; }
public Guid UserAccountID { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime Expiry { get; set; }
public string Hash { get; set; } = null!;
public virtual UserAccount UserAccount { get; set; } = null!;
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class UserFollow
{
public Guid UserFollowID { get; set; }
public Guid UserAccountID { get; set; }
public Guid FollowingID { get; set; }
public DateTime CreatedAt { get; set; }
public virtual UserAccount Following { get; set; } = null!;
public virtual UserAccount UserAccount { get; set; } = null!;
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace DataAccessLayer;
public partial class UserVerification
{
public Guid UserVerificationID { get; set; }
public Guid UserAccountID { get; set; }
public DateTime VerificationDateTime { get; set; }
public virtual UserAccount UserAccount { get; set; } = null!;
}

31
biergarten.sln Normal file
View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36603.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccessLayer", "DataAccessLayer\DataAccessLayer.csproj", "{A9FCCEB3-DD88-F8C0-89A3-FD31A7C54F23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccessLayer-Tests", "DataAccessLayer-Tests\DataAccessLayer-Tests.csproj", "{3638DC4E-D4C8-4DBE-CF3B-EF2C805509CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9FCCEB3-DD88-F8C0-89A3-FD31A7C54F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9FCCEB3-DD88-F8C0-89A3-FD31A7C54F23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9FCCEB3-DD88-F8C0-89A3-FD31A7C54F23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9FCCEB3-DD88-F8C0-89A3-FD31A7C54F23}.Release|Any CPU.Build.0 = Release|Any CPU
{3638DC4E-D4C8-4DBE-CF3B-EF2C805509CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3638DC4E-D4C8-4DBE-CF3B-EF2C805509CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3638DC4E-D4C8-4DBE-CF3B-EF2C805509CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3638DC4E-D4C8-4DBE-CF3B-EF2C805509CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AF13035-54A8-46EA-8BED-866F683D9AED}
EndGlobalSection
EndGlobal

View File

@@ -321,12 +321,12 @@ CREATE TABLE BeerPost
Name NVARCHAR(100) NOT NULL,
Description NVARCHAR(MAX),
Description NVARCHAR(MAX) NOT NULL,
ABV DECIMAL(4,2),
ABV DECIMAL(4,2) NOT NULL,
-- Alcohol By Volume (typically 0-67%)
IBU INT,
IBU INT NOT NULL,
-- International Bitterness Units (typically 0-100)
PostedByID UNIQUEIDENTIFIER NOT NULL,
@@ -408,3 +408,11 @@ ON BeerPostPhoto(BeerPostID, PhotoID);
----------------------------------------------------------------------------
----------------------------------------------------------------------------
/*
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Scaffold-DbContext "Server=(localdb)\ProjectModels;Database=Biergarten;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -Context BiergartenContext -UseDatabaseNames -Force
*/