locked
DB problem with Azure sample app RRS feed

  • Question

  • User65893105 posted

    Im teaching myself how to develop wirh Azure and am using the Contoso ad application as a starting point.  This uses codefirst to generate the database which works ok.  Ive discovered a problem with the thumbnail creation process (it doesnt work, no thumbnail url is saved)

    during debug, im getting this error in the ProcessQueueMessage method on this line

    // Queue message contains AdId.
    var adId = int.Parse(msg.AsString);


    Ad ad = db.Ads.Find(adId);  ---->  error occurs here

    System.Data.SqlClient.SqlException was unhandled
    class="16"
    ErrorCode=-2146232060
    HResult=-2146232060
    LineNumber=1
    Message=Cannot create file 'C:\Users\Mark\ContosoAds.mdf' because it already exists. Change the file path or the file name, and retry the operation.
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

    so the database was created first time around and now exists, so why am I getting this error ?  Im new to Azure and codefirst development so any help would be appreciated 

    Friday, June 10, 2016 10:48 AM

All replies

  • User753101303 posted

    Hi,

    But for now it happens on your dev machine? Check perhaps your connection string as well as which file is found at c:\users\Mark\ConsotoAds.mdf. For example technically speaking this mdf file could be not attached to the SQL Server engine and EF could be setup to always drop and create the db.

    So EF won't drop this file because on the db side this database is not exposed and then when it tries to create the db with the underlying file it fails because this file already exists. Merely a guess for now but more likely it is just unrelated to using Azure.

    Friday, June 10, 2016 12:06 PM