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

  • At Build 2026, Microsoft Sets Up Windows as an OS for AI Agents

    Microsoft's Build 2026 Windows developer announcements point to a broader platform strategy for agentic AI, spanning terminal workflows, local models, app-building skills, Cloud PCs and operating system-level containment.

  • Slammed by Copilot Usage-Based Billing on Day 1, Facing $180 Bill for June

    A journalist using GitHub Copilot Pro details how a broken editorial workflow on day one of usage-based billing led to runaway token consumption, a projected $180 monthly bill, and practical tactics for cutting AI credit burn.

  • AdaBoost.R2 Regression Using C#

    AdaBoost.R2 regression works by building an ensemble of decision trees, training them on reweighted data, and combining their predictions with a weighted median, while also showing how parameter choices affect accuracy and overfitting.

  • VS Code 1.122 Lets BYOK Work Without GitHub Sign-In

    Microsoft's May 2026 VS Code update makes BYOK usable in restricted environments while adding agent, browser and issue-reporting updates.

Subscribe on YouTube