Entity Framework Code-First Migrations: Listing 1

DataBaseStruct.vb

Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations

'*** Note: This is the "DataAccess" Namespace ***

#Region "Table Classes"
'************************************************************************************************
'Classes describing individual table structure for each table identified in the context database
'************************************************************************************************

<Table("VehicleTable")>
Public Class Vehicle
Public Property VehicleId() As Int32
<Column("MakeOfCar")>
Public Property Make() As String
Public Property Model() As String
Public Property VehicleType() As VehicleType
Public Property VIN() As String            'New Property Added
Public Property LicensePlate() As String   'New Property Added
End Class

Public Class VehicleType
Public Property VehicleTypeId() As Int32
Public Property Name() As String
Public Property Description() As String
Public Property NumberOfAxles As Int32     'New Property Added
End Class

#End Region

#Region "Context Class"
'*******************************************************
'Context class describing Database and its tables
'*******************************************************
Public Class TransportationDB
Inherits DbContext

Public Property Vehicles() As DbSet(Of Vehicle)
Public Property VehicleTypes() As DbSet(Of VehicleType)

End Class

#End Region

About the Author

Sam Nasr has been a software developer since 1995, focusing mostly on Microsoft technologies. Having achieved multiple certifications from Microsoft (MCAD, MCTS(MOSS), and MCT), Sam develops, teaches, and tours the country to present various topics in .Net Framework. He is also actively involved with the Cleveland C#/VB.Net User Group, where he has been the group leader since 2003. In addition, he also started the Cleveland WPF Users Group in June 2009, and the Cleveland .Net Study Group in August 2009, and is the INETA mentor for Ohio. When not coding, Sam loves spending time with his family and friends or volunteering at his local church. He can be reached by email at [email protected]

comments powered by Disqus

Featured

  • Visual Studio 2022 for Mac Dumps Mono for .NET 6

    Visual Studio for Mac has parted ways with the Mono runtime in the just-published Preview 5, now running on .NET 6.

  • .NET Community Toolkit v8.0 Preview Revamps MVVM Library

    Microsoft announced the first preview of .NET Community Toolkit v8.0.0, which revamps the MVVM library and introduces a new GitHub repo to host the project.

  • Microsoft Details Native Integration of Elastic on Azure

    Microsoft detailed the native integration of Elastic tech with its Azure cloud computing platform, increasing application observability.

  • Java on Visual Studio Code Going Cloud Native

    Cloud-native development figures prominently in a new roadmap published by Microsoft's Java on Visual Studio Code dev team.

Upcoming Events