को सहेजते समय गलत मान मुझे माइग्रेशन में एक पूर्णांक कॉलम में मैप करने के लिए एंटीटी फ्रेमवर्क 5 एन्म्स प्राप्त करने में थोड़ा कठिनाई हो रही है। यह उनके डेटाबेस में प्रतिबिंबित नहीं करता है जब मैं परिवर्तनों को सहेजने केenum
public partial class EnumTest : DbMigration
{
public override void Up()
{
AddColumn("UserProfile", "Status", c => c.Int(nullable: false, defaultValue:1));
}
public override void Down()
{
DropColumn("UserProfile", "Status");
}
}
हालांकि: माइग्रेशन
[Table("UserProfile")]
public class UserProfile
{
public enum StudentStatusType
{
Student = 1,
Graduate = 2
}
[Key]
public int UserId { get; set; }
public string UserName { get; set; }
public string FullName { get; set; }
public StudentStatusType Status { get; set; }
}
इस तरह दिखता है: यहाँ क्या कोड की तरह लग रहा है।
var user = new UserProfile();
user.Status = UserProfile.StudentStatusType.Graduate;
user.FullName = "new";
user.UserName = "new";
users.UserProfiles.Add(user);
users.SaveChanges();
डेटाबेस:
----------------------------------------------------
|UserId | UserName | FullName | Status |
----------------------------------------------------
|1 | new | new | 1 |
----------------------------------------------------
क्या आप किसी भी मौके से .NET Framework 4 को लक्षित कर रहे हैं, न कि .NET Framework 4.5? – Pawel
मैं .NET Framework 4.5 को लक्षित कर रहा हूं। –