diff options
author | crupest <crupest@outlook.com> | 2019-04-12 23:34:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-12 23:34:40 +0800 |
commit | 1d184c3f41da806803c1ee792395eabcd155077d (patch) | |
tree | 0fa205ca1c58766101ae7f6c78be5ff2d77a0f28 /Timeline/Models/DatabaseContext.cs | |
parent | 19cae15eba2bcede41b818e1b8ab7fd5ac92eb05 (diff) | |
download | timeline-1d184c3f41da806803c1ee792395eabcd155077d.tar.gz timeline-1d184c3f41da806803c1ee792395eabcd155077d.tar.bz2 timeline-1d184c3f41da806803c1ee792395eabcd155077d.zip |
Add database connection.
Diffstat (limited to 'Timeline/Models/DatabaseContext.cs')
-rw-r--r-- | Timeline/Models/DatabaseContext.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Timeline/Models/DatabaseContext.cs b/Timeline/Models/DatabaseContext.cs new file mode 100644 index 00000000..1e89ea82 --- /dev/null +++ b/Timeline/Models/DatabaseContext.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Timeline.Models +{ + [Table("user")] + public class User + { + [Column("id"), Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long Id { get; set; } + + [Column("name"), Required] + public string Name { get; set; } + + [Column("password"), Required] + public string EncryptedPassword { get; set; } + + [Column("roles"), Required] + public string RoleString { get; set; } + } + + public class DatabaseContext : DbContext + { + public DatabaseContext(DbContextOptions<DatabaseContext> options) + : base(options) + { + + } + + public DbSet<User> Users { get; set; } + } +} |