c# - Entity Framework Code First - Reference same table -


I'm still starting with the unit framework code first. I want to select a resource to select a resource when creating a new resource, how do I reference the resource with the resource model?

  public class resources {public full resources id {get; Set; } [Required] [datatype (datatype. Email address)] [email address] receive public string email address; Set; } [Required] Public string password {get; Set; } Public string full name {get; Set; } Public at Time ManagerID {Received; Set; } Public perfection TravelManagerId {get; Set; } Public int overtime domainager {get; Set; } Public Completion Absence Manager {Received; Set; } Public Virtual Resources Time Manager {Received; Set; } Public Virtual Resources Travel Manager {Received; Set; } Public Virtual Resources Overtime Manager {Received; Set; } Public Virtual Resources Absence Manager {Received; Set; }}  

I think you are very close! If you want to do this from the conference, you can change the foreign key in your model as [Navigation Property Name] [Primary Primary Key Property Name]. Specifically, change id to ResourceId so that it matches the primary of the table that you are referring to (which is itself) ...

  public at Timemaner resource id {received; Set; } Public perfection TravelManagerResourceId {get; Set; } Public int overtime manager resourcesource {received; Set; } Public Completeness Absent NegativeSource ID {Receive; Set; }  

Since you are starting with the first EF code, I recommend you install the unit framework power tools, you will be able to right-click on the .cs file containing your DbContext, And it will generate a reading-only diagram of mapping.

Try it with your current model ... Click on the unit in the right diagram and see table mapping. You will see that EF was not able to locate your foreign keys and made 4 more for you. Once you make the above changes, recreate the image and see the difference.

EDIT: The code first docs in the conventions ...


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -