entity framework property can't be set to string, has to be nullable int

c# entity-framework entity-framework-6 sql

Question

The 'EmpGipNumber' property on 'Employee' could not be set to a 'System.String' value. You must set this property to a non-null value of type 'System.Int32'.

I'm getting this error, and my Employee Model's EmpGipNumber property is declared like this:

public virtual int? EmpGipNumber {get;set;}

why is it complaining, its a nullable int already. Ever since I enabled migrations I've been running into a large amount of problems.

The initial migration is empty because I enabled migrations on an existing database. The second migration is this:

public override void Up()
        {
            AlterColumn("dbo.Employee", "EmpGipNumber", c => c.Int());
        }

it was working fine yesterday. Me going to sleep must've angered it

1
-1
1/30/2015 2:06:55 PM

Accepted Answer

Without seeing more code, I'm wondering if it's a data issue. In my experience, it will convert any strings that tha can be parsed into ints... have you verified that the data you're converting can be parsed into an int?

1
1/30/2015 2:13:05 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow