Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Apr 14, 2012 07:44 PM|LINK
I have a created Entity Framework.I am trying to add a new songs and New album to the table. For example when I try to add a new song I used the method below and it tells me "Object reference not set to an instance of an object" on the s.Artist.ArtistName.
I have a webform that shows a list of Artists in a drop down menu and now I want to add a new song for that artist. How do I do that?
public Song AddNewSongNav(String ArtistName, String SongName)
using (var context = new MyEntities())
var s = new Song();
s.SongTitle = SongName;
s.Artist.ArtistName = ArtistName;
The frame work for the Artist Table has ArtistID,ArtistName and WikiPediaURL. It has a navivgation property for Album and Song. It is linked to Song as 1 to many and Album as 1 to Many.
It has a Song table, which has a SongID, SongTitle and Artist_ArtistID. It has a navigation property of Artist and Album. It's linked as a many to many to the Albums table.
Finally the Album table has an AlbumID,AlbumTitle,CoverArt,Year,Genre,MimeType and Artist_ArtistID. It has a navigation property of Artist and Song.
<input id="gwProxy" type="hidden" />
<input onclick="jsCall();" id="jsProxy" type="hidden" />