From 5e688a24d59299cde3c64cbe4153c4c0c19bc32b Mon Sep 17 00:00:00 2001 From: Kevin Matsubara Date: Fri, 4 Apr 2025 15:41:45 +0200 Subject: [PATCH] Add models for BaseDomainModel, Coach and Team. --- EntityFrameworkCore.Domain/BaseDomainModel.cs | 6 ++++++ EntityFrameworkCore.Domain/Class1.cs | 6 ------ EntityFrameworkCore.Domain/Coach.cs | 8 ++++++++ EntityFrameworkCore.Domain/Team.cs | 7 +++++++ 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 EntityFrameworkCore.Domain/BaseDomainModel.cs delete mode 100644 EntityFrameworkCore.Domain/Class1.cs create mode 100644 EntityFrameworkCore.Domain/Coach.cs create mode 100644 EntityFrameworkCore.Domain/Team.cs diff --git a/EntityFrameworkCore.Domain/BaseDomainModel.cs b/EntityFrameworkCore.Domain/BaseDomainModel.cs new file mode 100644 index 0000000..3715b8c --- /dev/null +++ b/EntityFrameworkCore.Domain/BaseDomainModel.cs @@ -0,0 +1,6 @@ +namespace EntityFrameworkCore.Domain; +// Since C#11, you do not need to wrap in accolades anymore. +public abstract class BaseDomainModel +{ + public DateTime CreatedDate { get; set;} +} diff --git a/EntityFrameworkCore.Domain/Class1.cs b/EntityFrameworkCore.Domain/Class1.cs deleted file mode 100644 index 8c55f06..0000000 --- a/EntityFrameworkCore.Domain/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace EntityFrameworkCore.Domain; - -public class Class1 -{ - -} diff --git a/EntityFrameworkCore.Domain/Coach.cs b/EntityFrameworkCore.Domain/Coach.cs new file mode 100644 index 0000000..6ad7072 --- /dev/null +++ b/EntityFrameworkCore.Domain/Coach.cs @@ -0,0 +1,8 @@ +namespace EntityFrameworkCore.Domain; +// Since C#11, you do not need to wrap in accolades anymore. +public class Coach : BaseDomainModel +{ + public int Id { get; set; } // Anything called "Id" is automatically a Primary Key. + public string Name { get; set; } // Strings are automatically become VARCHAR database types. +} + diff --git a/EntityFrameworkCore.Domain/Team.cs b/EntityFrameworkCore.Domain/Team.cs new file mode 100644 index 0000000..00dc1a3 --- /dev/null +++ b/EntityFrameworkCore.Domain/Team.cs @@ -0,0 +1,7 @@ +namespace EntityFrameworkCore.Domain; +// Since C#11, you do not need to wrap in accolades anymore. +public class Team : BaseDomainModel +{ + public int TeamId { get; set;} // This naming convention also allows EF to see this as a PK. + public string? Name { get; set; } +}