Skip to content

Commit

Permalink
AUTO MAPPING OBJECT - FAST FOOD - WEB PROJECT
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicTheCat committed Mar 28, 2019
1 parent a8ac6a3 commit 9b675e9
Show file tree
Hide file tree
Showing 100 changed files with 25,806 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FastFood.Models\FastFood.Models.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace FastFood.Data
{
using Microsoft.EntityFrameworkCore;
using Models;

public class FastFoodContext : DbContext
{
public FastFoodContext()
{

}

public FastFoodContext(DbContextOptions<FastFoodContext> options)
: base(options)
{
}

public DbSet<Category> Categories { get; set; }

public DbSet<Employee> Employees { get; set; }

public DbSet<Item> Items { get; set; }

public DbSet<Order> Orders { get; set; }

public DbSet<OrderItem> OrderItems { get; set; }

public DbSet<Position> Positions { get; set; }

protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<OrderItem>()
.HasKey(oi => new { oi.OrderId, oi.ItemId });

builder.Entity<Position>()
.HasAlternateKey(p => p.Name);

builder.Entity<Item>()
.HasAlternateKey(i => i.Name);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b675e9

Please sign in to comment.