Add vehicle service model and migration

This commit is contained in:
2015-10-07 23:28:58 -04:00
parent 41adb2298b
commit 306381b3c6
5 changed files with 224 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ namespace MileageTraker.Web.Context
public DbSet<Role> Roles { get; set; } public DbSet<Role> Roles { get; set; }
public DbSet<PurposeType> PurposeTypes { get; set; } public DbSet<PurposeType> PurposeTypes { get; set; }
public DbSet<FuelLog> FuelLogs { get; set; } public DbSet<FuelLog> FuelLogs { get; set; }
public DbSet<VehicleService> VehicleServices { get; set; }
/* /*
* WebSecurity.Register("Demo", "123456", "demo@demo.com", true, "Demo", "Demo"); * WebSecurity.Register("Demo", "123456", "demo@demo.com", true, "Demo", "Demo");
@@ -0,0 +1,29 @@
// <auto-generated />
namespace MileageTraker.Web.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
public sealed partial class VehicleService : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(VehicleService));
string IMigrationMetadata.Id
{
get { return "201510070326593_VehicleService"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,35 @@
namespace MileageTraker.Web.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class VehicleService : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.VehicleService",
c => new
{
VehicleServiceId = c.Int(nullable: false, identity: true),
InvoiceDate = c.DateTime(nullable: false),
ServiceCenterName = c.String(nullable: false, maxLength: 64),
InvoiceNumber = c.String(nullable: false, maxLength: 32),
Price = c.Decimal(nullable: false, precision: 18, scale: 2),
Description = c.String(maxLength: 64),
Vehicle_VehicleId = c.String(nullable: false, maxLength: 6),
})
.PrimaryKey(t => t.VehicleServiceId)
.ForeignKey("dbo.Vehicle", t => t.Vehicle_VehicleId, cascadeDelete: true)
.Index(t => t.Vehicle_VehicleId);
}
public override void Down()
{
DropForeignKey("dbo.VehicleService", "Vehicle_VehicleId", "dbo.Vehicle");
DropIndex("dbo.VehicleService", new[] { "Vehicle_VehicleId" });
DropTable("dbo.VehicleService");
}
}
}
File diff suppressed because one or more lines are too long
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace MileageTraker.Web.Models
{
public class VehicleService
{
[Key]
public int VehicleServiceId { get; set; }
[Required]
public virtual Vehicle Vehicle { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormatAttribute(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public DateTime InvoiceDate { get; set; }
[Required]
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
public string ServiceCenterName { get; set; }
[Required]
[StringLength(32)]
public string InvoiceNumber { get; set; }
[Required]
public decimal Price { get; set; }
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
public string Description { get; set; }
}
}