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

  • IDE Irony: Coding Errors Cause 'Critical' Vulnerability in Visual Studio

    In a larger-than-normal Patch Tuesday, Microsoft warned of a "critical" vulnerability in Visual Studio that should be fixed immediately if automatic patching isn't enabled, ironically caused by coding errors.

  • Building Blazor Applications

    A trio of Blazor experts will conduct a full-day workshop for devs to learn everything about the tech a a March developer conference in Las Vegas keynoted by Microsoft execs and featuring many Microsoft devs.

  • Gradient Boosting Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the gradient boosting regression technique, where the goal is to predict a single numeric value. Compared to existing library implementations of gradient boosting regression, a from-scratch implementation allows much easier customization and integration with other .NET systems.

  • Microsoft Execs to Tackle AI and Cloud in Dev Conference Keynotes

    AI unsurprisingly is all over keynotes that Microsoft execs will helm to kick off the Visual Studio Live! developer conference in Las Vegas, March 10-14, which the company described as "a must-attend event."

  • Copilot Agentic AI Dev Environment Opens Up to All

    Microsoft removed waitlist restrictions for some of its most advanced GenAI tech, Copilot Workspace, recently made available as a technical preview.

Subscribe on YouTube