I have an MVC3 project using EF5 targeting ASP.NET framework 4.5 that I'm updating with some additional classes. One of my new classes has a nullable, nested enum property that is not being mapped to the database.
public class MyProblemClass
{
public MyClass.MyEnum? MyPropertyName { get; set; }
}
Here are some of the relevant details:
- The code generated by running
Add-Migration
doesn't contain this property. - I have created other new classes with basic enums that are mapped correctly.
- I have other existing classes with nested enums that are mapped correctly.
- If I put a basic enum in the problem class it maps correctly.
- If I put the problem enum in a different class it doesn't work there either.
By basic enums I mean ones that are defined outside of a class:
namespace My.Project.NewStuff
{
public enum MyEnum
{
Option1,
Option2
}
}
By nested enums I mean ones that are defined inside of a class:
namespace My.Project.NewStuff
{
public static class MyClass
{
public enum MyEnum
{
Option1,
Option2
}
public static string MyExtensionMethod (this MyEnum option) {...}
}
}
The new enum and class names are actually identical to an existing working one, but in a different namespace. The new one has slightly different options, and different code in the extension methods.
I have tried slightly renaming the class, enum and property to see if there are any bugs related to using the same name, but this didn't help.