c# - How to avoid entering values in tables that are just information tables asp.net mvc -


I have a model client:

  public class client {public int client id {get; Set; } [Required] public string compte {get; Set; } Public int Restr_typeID {get; Set; } Public Virtual Restr_type1 Restr_type {get; Set; }   

and Restr_type is also a model:

  public int Restr_type1ID {get; Set; } Public string restr1_name {get; Set; } Receive public integral {attief}; Set; } Received Public Virtual Actifs Actifs; Set; }   

My problem occurs when I add an instance of the client in the Customer table, it also adds a line in the Restr_types table and the Actifs table, but it has only two tablets in the information tables. And so I want them to be stable. What do I need to do is stock up only one customer

Can you help me?

Thank you for your help!

If you have EF works as an attachment object as a virtual property.

Actually if you create a new event of Client and populate the Restr_type property with a reference that you get from EF If it does, it will treat it as a new value of Restr_type property, so that it should be added to the DB and add a reference to it.

What you would like to do is use EF to query the database for Restr_type and use the reference returned from that reference. Otherwise simply pop up Restr_typeID and leave Restr_type when you call () on your reference. > I hope that makes sense that this can help you understand the EF context slightly better

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -