I am trying out my hand at data modeling, what I am trying to do is get an editor that allows me to create types with an FK reference in a main data table, and when the editors load, have selections rather than text fields.
http://www.asp.net/mvc/tutorials/mvc-music-store-part-5
I had assumed that the since MVC made the FK when it created the DB that is followed it as well when creating CRUD views, it appeared as though that was the case from the music store demo as their screen shows select lists and they even make a point to state that it uses them.
I have gone through the Music Store demo and I cannot tell what I have done wrong, model is as follows.
Many thanks in advance.
http://www.asp.net/mvc/tutorials/mvc-music-store-part-5
I had assumed that the since MVC made the FK when it created the DB that is followed it as well when creating CRUD views, it appeared as though that was the case from the music store demo as their screen shows select lists and they even make a point to state that it uses them.
I have gone through the Music Store demo and I cannot tell what I have done wrong, model is as follows.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
namespace MVCTests.Models
{
public class MachineType {
public int MachineTypeId { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "Type Display")]
public string Name { get; set; }
}
public class ReportType
{
public int ReportTypeId { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "Type Display")]
public string Name { get; set; }
}
public class Report
{
public int ReportId { get; set; }
//[Required]
[Display(Name = "Machine Type")]
public int MachineTypeId { get; set; }
// [Required]
[Display(Name = "Report Type")]
public int ReportTypeId { get; set; }
[Required(ErrorMessage="Error.")]
[DataType(DataType.Text)]
[Display(Name = "Display")]
public string display { get; set; }
[Required(ErrorMessage = "Error.")]
[DataType(DataType.Text)]
[Display(Name = "Data Label")]
public string data_label { get; set; }
[Required(ErrorMessage = "Error.")]
[DataType(DataType.Text)]
[Display(Name = "Report File")]
public string rpt_file { get; set; }
[Required(ErrorMessage = "Error.")]
[DataType(DataType.Text)]
[Display(Name = "Query File")]
public string qry_file { get; set; }
}
public class reportConfigurationEntitiy : DbContext
{
public DbSet<Report> Reports { get; set; }
public DbSet<MachineType> MachineTypes { get; set; }
public DbSet<ReportType> ReportTypes { get; set; }
}
}
Many thanks in advance.