entity framework - EF7 Scaffolding not creating columns -


i have model looks this:

public class order {     // removed irrelevant other properties     public guid id { get; set; }     public address buyeraddress { get; set; }     public address selleraddress { get; set; } }  public class address {     public guid id { get; set; }     public string street { get; set; }     public order order { get; set; } } 

in dbcontext hooked them this:

entitytypebuilder.hasone(x => x.buyeraddress).withone(x => x.order).isrequired(false); entitytypebuilder.hasone(x => x.selleraddress).withone(x => x.order).isrequired(false); 

when run

dnx ef migrations add foo dnx ef database update 

the table being created of properties, other properties, selleraddress missing (the buyeraddress being created fine though).

the same problem other entities, such user <-> bankaccount 1:1 relationship defined entitytypebuilder.hasone(x => x.bankaccount).withone(x => x.user).isrequired(false);

does know what's up? i'm using entity framework 7.0.0-rc1-final. issue driving me crazy.

i fixed problem. first had foreign key properties, models looked this:

public order order {get;set;} public guid orderid {get;set;} 

i didn't this, , resulted in duplicate columns in database, removed [entityname]id properties model. because of this, ef got confused not longer figure out trying do. 1:1 relationships removed navigation property on 1 side of equation (so order has reference address, address no longer has navigation property order). solved problem.

so in case of sample code in question, removed order property address.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -