More in this section
Forums / Set-up & Installation / Import News content into Sitefinity database

Import News content into Sitefinity database

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 1 answered
  1. promedia
    promedia avatar
    4 posts
    16 Aug 2004
    12 Nov 2009
    Link to this post

    We're in the middle of moving our existing ASP.NET web site to Sitefinity. We're trying to import our existing News content directly into the Sitefinity database. Our news content is stored in SQL Server 2008 database using a very simple table structure.

    We can see that  /News data is stored in Sitefinity in two tables: sf_CmsContentBase and sf_CmsTextContent

    Is there a tutorial or walkthrough showing how this can be done? We need to move the existing content into Sitefinity so that our existing content will appear in the Sitefinity News sections.



  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    12 Nov 2009
    Link to this post
    Hi promedia,

    I suggest that you should use the news API to migrate the old news items. It will be easy and this will ensure that there will not be further problems. We use Nolics queries and Sitefinity's API to insert, update, delete content items. There are many internal dependencies between the tables and we do not suggest working directly with the database.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. promedia
    promedia avatar
    4 posts
    16 Aug 2004
    20 Nov 2009
    Link to this post
    1 /* Here is the code we used to connect to our legacy database, loop through each record in
    * the News table, then create a Sitefinity News item for each record. */  
    2         // Create a DataContext for legacy database 
    3         Legacy_DataContext dc = new Legacy_DataContext(); 
    5         // simple LINQ query to get news items from legacy database 
    6         var newsQuery = from newsbrief in dc.News_Briefs 
    7                         select newsbrief; 
    9         // Create a News item in Sitefinity for each news item in legacy database 
    10         foreach (var nb in newsQuery) 
    11         { 
    12             NewsManager newsBriefs = new NewsManager("News"); 
    13             IContent newsContent = newsBriefs.Content.CreateContent("text/html"); 
    15             newsContent.Content = nb.Body; 
    16             newsContent.Status = Telerik.Cms.Engine.ContentStatus.Published; 
    18             // Assign MetaData values from legacy database 
    19             newsContent.SetMetaData("Title", nb.Title); 
    21             newsContent.SetMetaData("Author""Editorial Staff"); 
    23             newsContent.SetMetaData("Summary", nb.Teaser); 
    24             newsContent.SetMetaData("Source""Original"); 
    26             DateTime dt = DateTime.Parse(nb.PostDate.ToString()); 
    27             DateTime edt = dt.AddMonths(6); 
    29             newsContent.SetMetaData("Publication_Date", dt); 
    30             newsContent.SetMetaData("Expiration_Date", edt); 
    32             newsBriefs.Content.SaveContent(newsContent); 
    33         } 
Register for webinar
3 posts, 1 answered