I have two class A and B. B has a foreign key to A.
class A {
byte Id{get; set;}
string Name{get;set;}
}
and
class B {
byte Id{get; set;}
string Name{get;set;}
A A{get;set;}
byte AId{get;set;}
}
My problem is:
- I created a class
Awith a propertyidof typeint - I run
update-database - I modified data type of
idtobyte - I run
update-databaseagain - I found that in table
Bthat useidofAas the foreign key has two columns, i.e.,aIdanda_Id.
My question is: how can I remove the column a_Id using code first approach? Or anyway that is feasible.
I tried to run the query: ALTER TABLE DROP COLUMN a_Id - failed because one or more objects access this column.
I also tried to delete the column directly using VS Server explorer, remove the column by using table definition. But it did not work too.
Thanks