Add .NET Core 2.1 versions
This commit is contained in:
16
worker/dotnet/Worker/Entities/Vote.cs
Normal file
16
worker/dotnet/Worker/Entities/Vote.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Worker.Entities
|
||||
{
|
||||
[Table("votes")]
|
||||
public class Vote
|
||||
{
|
||||
[Column("id")]
|
||||
[Key]
|
||||
public string VoterId { get; set; }
|
||||
|
||||
[Column("vote")]
|
||||
public string VoteOption { get; set; }
|
||||
}
|
||||
}
|
19
worker/dotnet/Worker/Entities/VoteContext.cs
Normal file
19
worker/dotnet/Worker/Entities/VoteContext.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Worker.Entities
|
||||
{
|
||||
public class VoteContext : DbContext
|
||||
{
|
||||
private static bool _EnsureCreated;
|
||||
public VoteContext(DbContextOptions options) : base(options)
|
||||
{
|
||||
if (!_EnsureCreated)
|
||||
{
|
||||
Database.EnsureCreated();
|
||||
_EnsureCreated = true;
|
||||
}
|
||||
}
|
||||
|
||||
public DbSet<Vote> Votes { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user