locked
web api sample RRS feed

Answers

All replies

  • User-1509636757 posted

    Try to change ConnectionString in web.config file:

    <connectionStrings>
        <add name="BookServiceContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=BookServiceContext-20140613003603; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20140613003603.mdf" providerName="System.Data.SqlClient"/>
      </connectionStrings>

    Change Data Source from (localdb)\v11.0 to your Sql Server 2014 express instance name.

    Wednesday, March 1, 2017 1:29 PM
  • User-709682174 posted

    Yes, I have modified, and I get the following screenshot:

    https://1drv.ms/i/s!AiYjxW6ElFsyvjNCRWjFYRdZDkGM

    whether I need to do some steps to complete the database.

    Wednesday, March 1, 2017 2:35 PM
  • User-709682174 posted

    and I get the following error, when i type 

    Add-Migration Initial
    Update-Database

    https://1drv.ms/i/s!AiYjxW6ElFsyvjSmTojv2QD3LBx1

    the document:

    https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-3 

    Wednesday, March 1, 2017 4:08 PM
  • User-2057865890 posted

    Hi Test888,

    You need to specify the connection string that will be used by your start-up project, make sure that you make your project as startup.

    Best Regards,

    Chris

    Thursday, March 2, 2017 6:59 AM
  • User-1509636757 posted

    Yes, I have modified, and I get the following screenshot:

    https://1drv.ms/i/s!AiYjxW6ElFsyvjNCRWjFYRdZDkGM

    whether I need to do some steps to complete the database.

    I think that is it, Quite possible that there are no Author records in database in Authors table. Try adding an Author record to fill the Authors Dropdown.

    Thursday, March 2, 2017 7:24 AM
  • User-1509636757 posted

    After manually adding Author in database, I am successfully able to add books and view Books details:

    Thursday, March 2, 2017 7:37 AM
  • User-709682174 posted

    Hi friend,

    Would you mind share your project to One Drive and share a link here. That I could download it.

    Thursday, March 2, 2017 2:19 PM
  • User-1509636757 posted

    Download link: https://www.dropbox.com/s/7ybsrco08zv1bo9/BookService.zip?dl=0

    You may require to change connection string in web.config file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 2, 2017 2:40 PM