shanish
shanish

Reputation: 1984

passing value to the null value column in Sql

I have a Sections table and in that table I have columns SectionId,CourseId,Name,Capacity....here the CourseId is a null value column and its the Foreignkey here which focuses the Cousrse table....this CourseId column is a newly added one.

I am trying to add records to this table, am using entity framework, in the Entiry framework its showing all the column names except this CourseId, and when I send the datas to this Sections table all the datas except Course Id are stored fine...the value of courseId is stored as Null...

how can I pass the CourseId to this column......can anyone help me here

Upvotes: 3

Views: 242

Answers (2)

shanish
shanish

Reputation: 1984

Thanks everybody for ur kind responses, I found out the soultion, I solved the issue like

Public int CourseId
{
  get;
  set;
}

DataObject.Entities dataEntities=new DataObject.Entities();

   DataObject.Section section=dataEntities.Sections.CreateSections(0
                                                                    ,Name
                                                                    ,Code
                                                                    ,Capacity);
   section.CourseId=CourseId;
   dataEntities.Sections.AddObject(section);
   dataEntities.SaveChanges();

Upvotes: 0

SouthShoreAK
SouthShoreAK

Reputation: 4296

If EF is not showing your column, you may need to refresh your model. Start there.

  1. Open your .edmx file
  2. Right-click on the design surface
  3. Choose "Update Model From Database"
  4. Follow the instructions.

Upvotes: 4

Related Questions