I have class department inside container Containerclass as following
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- using System.Linq;
- using System.Web;
- namespace UniversityData.Models
- {
- [Table("Department")]
- public partial class Department
- {
- public Department()
- {
- }
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
- [Key]
- public int DepartmentID { get; set; }
- [Required]
- [StringLength(50)]
- public string DepartmentName { get; set; }
- [Required]
- [StringLength(50)]
- public string YearName { get; set; }
- }
- }
how to do that
my container class as following
- public partial class ContainerClass : DbContext
- {
- public ContainerClass() : base("name=mycon")
- {
- }
- public virtual DbSet
Departments { get; set; } - }
to make DepartmentID IDENTITY then make migrations
Bikesh SrivastavaPosted Nov 11, 2016, 12:17 AM