-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModels.cs
More file actions
41 lines (36 loc) · 1.26 KB
/
Models.cs
File metadata and controls
41 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace UserAPI
{
public class UserDbContext : DbContext
{
public UserDbContext(DbContextOptions<UserDbContext> options)
: base(options)
{ }
public DbSet<User> users { get; set; }
}
[Table("User")]
public class User
{
[Key]
public Guid UserId { get; set; }
public string UserName { get; set; }
public string UserNo { get; set; }
public DateTimeOffset CreatedDate { get; set; }
public DateTimeOffset ModifiedDate { get; set; }
}
public class UsersContextFactory : IDesignTimeDbContextFactory<UserDbContext>
{
public UserDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<UserDbContext>();
optionsBuilder.UseSqlServer("Server=HP-FIDELITY\\SQLEXPRESS;Database=UserDB;User Id=sa;password=sarvan@123;Trusted_Connection=False;MultipleActiveResultSets=true;");
return new UserDbContext(optionsBuilder.Options);
}
}
}