Given this code:
public class Car { public virtual int CarId { get; set; } public virtual string TypeName { get; set; } public ConvertableNullable<double> Price { get; set; } }
Where ConvertableNullable
is just a workaround to Nullable
, but it does not inherit from it.
Now, this is my simple context, where I map a car class to an entity and map each of its properties
public class MyDBContext : DbContext { public MyDBContext() : base( "data source=.;initial catalog=newDB1;integrated security=True;" + "multipleactiveresultsets=True;App=EntityFramework") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<Car>().HasKey(x=>x.CarId); modelBuilder.Entity<Car>().Property(x => x.TypeName); modelBuilder.Entity<Car>().Property(x => x.Price); } public DbSet<Car> Cars { get; set; } }
now when i try to deal with this context, it throws an exception
var db = new MyDBContext();
Any suggestions
source share