문제

I am new to EF. When I used DbContext Generator, it created separate partial classes for my entities. Next I added a property to one of the classes e.g. To the Users class I added a Phone property

 public partial class Users 
 { 
     public int UserId{get; set;} 
     /*new Property*/
     public int Phone{get; set;}
 }

But when I update the edmx, i.e. Update Model from Database, the new property is overwritten.

When I used Partial class instead of the DbContext Generator, the new property is not overwritten.

So what is the use of using Dbcontext generator then?

도움이 되었습니까?

해결책

Because you generate your model from an existing database you are using the Database First approache.

If you want the Phone property to be created on your Users class then you must add a column name Phone in the associated table. After that you update your model.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top