-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.vb
More file actions
51 lines (37 loc) · 1.71 KB
/
Copy pathCustomer.vb
File metadata and controls
51 lines (37 loc) · 1.71 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
42
43
44
45
46
47
48
49
50
51
Imports System.Collections.Generic
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema
Imports System.Data.Entity
Namespace GridViewOptimisticConcurrencyMvc.Models
Public Class Customer
<Key>
Public Property Id As Integer
Public Property FirstName As String
Public Property LastName As String
Public Property Age As Integer
Public Property Email As String
<Timestamp>
Public Property RowVersion As Byte()
End Class
Public Class CustomerDbContext
Inherits DbContext
Public Sub New()
MyBase.New("CustomerDbContext")
Call Database.SetInitializer(New CustomerDbContextInitializer())
End Sub
Public Property Customers As DbSet(Of Customer)
End Class
Public Class CustomerDbContextInitializer
Inherits DropCreateDatabaseIfModelChanges(Of CustomerDbContext)
Protected Overrides Sub Seed(ByVal context As CustomerDbContext)
Dim defaultCustomers As IList(Of Customer) = New List(Of Customer)()
defaultCustomers.Add(New Customer() With {.FirstName = "David", .LastName = "Adler", .Age = 25, .Email = "David.Adler@somewhere.com"})
defaultCustomers.Add(New Customer() With {.FirstName = "Michael", .LastName = "Alcamo", .Age = 38, .Email = "Michael.Alcamo@somewhere.com"})
defaultCustomers.Add(New Customer() With {.FirstName = "Amy", .LastName = "Altmann", .Age = 27, .Email = "Amy.Altmann@somewhere.com"})
For Each std As Customer In defaultCustomers
context.Customers.Add(std)
Next
MyBase.Seed(context)
End Sub
End Class
End Namespace