Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. How to insert table values using Entity frame work (Foreign key)???

How to insert table values using Entity frame work (Foreign key)???

Scheduled Pinned Locked Moved LINQ
helpquestiontutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alim12345
    wrote on last edited by
    #1

    Hi I have 2 table, Tab1(TID,Name Number) TID is PK Tab2(MID,TID,Description) TID is FK Both table data coming from different screens.... So i have 2 insert data individually So how can I insert? My Code: Tab1 T1=Tab1.CreateTab1(0); Tab2 T2 = Tab2.CreateTab2(0); T2.MID=200; T2.TID=300; T2.Description="Hellow"; Connection.AddToTab2(T2); Connection.SaveChanges(); But data is not inserting... its giving error.. Can some one help me plz..>>>

    T D 2 Replies Last reply
    0
    • A Alim12345

      Hi I have 2 table, Tab1(TID,Name Number) TID is PK Tab2(MID,TID,Description) TID is FK Both table data coming from different screens.... So i have 2 insert data individually So how can I insert? My Code: Tab1 T1=Tab1.CreateTab1(0); Tab2 T2 = Tab2.CreateTab2(0); T2.MID=200; T2.TID=300; T2.Description="Hellow"; Connection.AddToTab2(T2); Connection.SaveChanges(); But data is not inserting... its giving error.. Can some one help me plz..>>>

      T Offline
      T Offline
      Thanigainathan S
      wrote on last edited by
      #2

      Hi, Are you doing this in LINQ ? If so you wont be getting thisd trouble. Thanks, Thani

      India is Mythical and so we are

      A 1 Reply Last reply
      0
      • T Thanigainathan S

        Hi, Are you doing this in LINQ ? If so you wont be getting thisd trouble. Thanks, Thani

        India is Mythical and so we are

        A Offline
        A Offline
        Alim12345
        wrote on last edited by
        #3

        No i am using Entity Frame work

        T 1 Reply Last reply
        0
        • A Alim12345

          No i am using Entity Frame work

          T Offline
          T Offline
          Thanigainathan S
          wrote on last edited by
          #4

          HI, Why do you need to create tables ? you can create objects right. Create object ,assign property values and save them. Thanks, Thani

          India is Mythical and so we are

          A 1 Reply Last reply
          0
          • T Thanigainathan S

            HI, Why do you need to create tables ? you can create objects right. Create object ,assign property values and save them. Thanks, Thani

            India is Mythical and so we are

            A Offline
            A Offline
            Alim12345
            wrote on last edited by
            #5

            ya i am doing like that only dear...

            1 Reply Last reply
            0
            • A Alim12345

              Hi I have 2 table, Tab1(TID,Name Number) TID is PK Tab2(MID,TID,Description) TID is FK Both table data coming from different screens.... So i have 2 insert data individually So how can I insert? My Code: Tab1 T1=Tab1.CreateTab1(0); Tab2 T2 = Tab2.CreateTab2(0); T2.MID=200; T2.TID=300; T2.Description="Hellow"; Connection.AddToTab2(T2); Connection.SaveChanges(); But data is not inserting... its giving error.. Can some one help me plz..>>>

              D Offline
              D Offline
              DoctorMick
              wrote on last edited by
              #6

              What is the error?

              T 1 Reply Last reply
              0
              • D DoctorMick

                What is the error?

                T Offline
                T Offline
                Tauseef A
                wrote on last edited by
                #7

                you will have to create a procedure for that in order to insert values in the child table but not in the parent table .

                Tauseef A Khan MCP Dotnet framework 2.0.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups