示例#1
0
 public CreateModel(BravisDbContext db)
 {
     _db = db;
 }
示例#2
0
 public EditModel(BravisDbContext db)
 {
     _db = db;
 }
示例#3
0
 // Using DI to access the Db context.
 public IndexModel(BravisDbContext db)
 {
     _db = db;
 }
示例#4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new BravisDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <BravisDbContext> >()))
            {
                // Look for any WorkOrders.
                if (context.WorkOrders.Any())
                {
                    return;   // DB has been seeded
                }

                context.WorkOrders.AddRange(
                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                }
                    );
                context.SaveChanges();
            }
        }