Skip to content

Commit

Permalink
Simplify entity definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
davewalker5 committed Apr 13, 2020
1 parent 3131b72 commit 465a39f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/FlightRecorder.Data/FlightRecorder.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageId>FlightRecorder.Data</PackageId>
<PackageVersion>1.0.0.1</PackageVersion>
<PackageVersion>1.0.0.2</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020</Copyright>
<Owners>Dave Walker</Owners>
<PackageReleaseNotes>First Release</PackageReleaseNotes>
<PackageReleaseNotes>Modifications for service implementation</PackageReleaseNotes>
<Summary>Flight Recorder EF Core Database Layer</Summary>
<PackageTags>FlightRecorder database</PackageTags>
<Title>Flight Recorder EF Core Database Layer</Title>
Expand Down
24 changes: 0 additions & 24 deletions src/FlightRecorder.Data/FlightRecorderDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnName("serial_number")
.HasColumnType("VARCHAR(50)");
entity.HasOne(d => d.Model)
.WithMany(p => p.Aircraft)
.HasForeignKey(d => d.ModelId);
});

modelBuilder.Entity<Airline>(entity =>
Expand Down Expand Up @@ -91,10 +87,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnName("number")
.HasColumnType("VARCHAR(50)");
entity.HasOne(d => d.Airline)
.WithMany(p => p.Flight)
.HasForeignKey(d => d.AirlineId);
});

modelBuilder.Entity<Location>(entity =>
Expand Down Expand Up @@ -139,10 +131,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnName("name")
.HasColumnType("VARCHAR(100)");
entity.HasOne(d => d.Manufacturer)
.WithMany(p => p.Model)
.HasForeignKey(d => d.ManufacturerId);
});

modelBuilder.Entity<Sighting>(entity =>
Expand All @@ -165,18 +153,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.FlightId).HasColumnName("flight_id");
entity.Property(e => e.LocationId).HasColumnName("location_id");
entity.HasOne(d => d.Aircraft)
.WithMany(p => p.Sighting)
.HasForeignKey(d => d.AircraftId);
entity.HasOne(d => d.Flight)
.WithMany(p => p.Sighting)
.HasForeignKey(d => d.FlightId);
entity.HasOne(d => d.Location)
.WithMany(p => p.Sighting)
.HasForeignKey(d => d.LocationId);
});


Expand Down
9 changes: 1 addition & 8 deletions src/FlightRecorder.Entities/Db/Aircraft.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Aircraft
{
public Aircraft()
{
Sighting = new HashSet<Sighting>();
}

[Key]
public long Id { get; set; }
public long ModelId { get; set; }
Expand All @@ -20,6 +14,5 @@ public Aircraft()
public long Manufactured { get; set; }

public virtual Model Model { get; set; }
public virtual ICollection<Sighting> Sighting { get; set; }
}
}
10 changes: 1 addition & 9 deletions src/FlightRecorder.Entities/Db/Airline.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Airline
{
public Airline()
{
Flight = new HashSet<Flight>();
}

[Key]
public long Id { get; set; }
public string Name { get; set; }

public virtual ICollection<Flight> Flight { get; set; }
}
}
9 changes: 1 addition & 8 deletions src/FlightRecorder.Entities/Db/Flight.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Flight
{
public Flight()
{
Sighting = new HashSet<Sighting>();
}

[Key]
public long Id { get; set; }
public long AirlineId { get; set; }
Expand All @@ -20,6 +14,5 @@ public Flight()
public string Destination { get; set; }

public virtual Airline Airline { get; set; }
public virtual ICollection<Sighting> Sighting { get; set; }
}
}
10 changes: 1 addition & 9 deletions src/FlightRecorder.Entities/Db/Location.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Location
{
public Location()
{
Sighting = new HashSet<Sighting>();
}

[Key]
public long Id { get; set; }
public string Name { get; set; }

public virtual ICollection<Sighting> Sighting { get; set; }
}
}
10 changes: 1 addition & 9 deletions src/FlightRecorder.Entities/Db/Manufacturer.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Manufacturer
{
public Manufacturer()
{
Model = new HashSet<Model>();
}

[Key]
public long Id { get; set; }
public string Name { get; set; }

public virtual ICollection<Model> Model { get; set; }
}
}
9 changes: 1 addition & 8 deletions src/FlightRecorder.Entities/Db/Model.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace FlightRecorder.Entities.Db
{
[ExcludeFromCodeCoverage]
public partial class Model
{
public Model()
{
Aircraft = new HashSet<Aircraft>();
}

[Key]
public long Id { get; set; }
public long ManufacturerId { get; set; }
public string Name { get; set; }

public virtual Manufacturer Manufacturer { get; set; }
public virtual ICollection<Aircraft> Aircraft { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/FlightRecorder.Entities/FlightRecorder.Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageId>FlightRecorder.Entities</PackageId>
<PackageVersion>1.0.0.2</PackageVersion>
<PackageVersion>1.0.0.3</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020</Copyright>
<Owners>Dave Walker</Owners>
<PackageReleaseNotes>First Release</PackageReleaseNotes>
<PackageReleaseNotes>Updates for REST service implementation</PackageReleaseNotes>
<Summary>Flight Recorder Domain Models</Summary>
<PackageTags>FlightRecorder domain models entities</PackageTags>
<Title>Flight Recorder Domain Models</Title>
Expand Down
20 changes: 10 additions & 10 deletions src/FlightRecorderDb.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.BusinessLogi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.DataExchange", "FlightRecorder.DataExchange\FlightRecorder.DataExchange.csproj", "{2337BD55-D981-459A-ACD9-F0CFE5DCC1AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.Migrations", "FlightRecorder.Migrations\FlightRecorder.Migrations.csproj", "{C900A267-3486-430A-ABB5-1D25292BE450}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.Migrations", "FlightRecorder.Migrations\FlightRecorder.Migrations.csproj", "{67B116B7-F37B-492C-B6A8-767617CC89E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.Users", "FlightRecorder.Users\FlightRecorder.Users.csproj", "{B17F7264-1B0D-48AA-829F-83E0E0A13670}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRecorder.Users", "FlightRecorder.Users\FlightRecorder.Users.csproj", "{5C0B6862-4FC3-42DC-9CF0-ECBB5929A09B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -41,13 +41,13 @@ Global
{2337BD55-D981-459A-ACD9-F0CFE5DCC1AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2337BD55-D981-459A-ACD9-F0CFE5DCC1AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2337BD55-D981-459A-ACD9-F0CFE5DCC1AA}.Release|Any CPU.Build.0 = Release|Any CPU
{C900A267-3486-430A-ABB5-1D25292BE450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C900A267-3486-430A-ABB5-1D25292BE450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C900A267-3486-430A-ABB5-1D25292BE450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C900A267-3486-430A-ABB5-1D25292BE450}.Release|Any CPU.Build.0 = Release|Any CPU
{B17F7264-1B0D-48AA-829F-83E0E0A13670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B17F7264-1B0D-48AA-829F-83E0E0A13670}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B17F7264-1B0D-48AA-829F-83E0E0A13670}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B17F7264-1B0D-48AA-829F-83E0E0A13670}.Release|Any CPU.Build.0 = Release|Any CPU
{67B116B7-F37B-492C-B6A8-767617CC89E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67B116B7-F37B-492C-B6A8-767617CC89E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67B116B7-F37B-492C-B6A8-767617CC89E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67B116B7-F37B-492C-B6A8-767617CC89E4}.Release|Any CPU.Build.0 = Release|Any CPU
{5C0B6862-4FC3-42DC-9CF0-ECBB5929A09B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C0B6862-4FC3-42DC-9CF0-ECBB5929A09B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C0B6862-4FC3-42DC-9CF0-ECBB5929A09B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C0B6862-4FC3-42DC-9CF0-ECBB5929A09B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 465a39f

Please sign in to comment.