Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:01:45+00:00 2026-06-16T21:01:45+00:00

I seem to be having a problem with Entity Framework code-first. I managed to

  • 0

I seem to be having a problem with Entity Framework code-first. I managed to make it create the database in my project folder in App_data and everything works well if I do not try to check the contents of the generated database in the Server Explorer.

If I do that and try to open the application I get this error:

Cannot open database “SellCars” requested by the login. The login failed.
Login failed for user ‘Aly-PC\Aly’.

While this behavior may be normal (not really sure), even if I detach the db and close the connection in the server explorer and I run this application it still does not work but instead in throws this error:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
Cannot open database “SellCars” requested by the login. The login failed.
Login failed for user ‘Aly-PC\Aly’.
Log file ‘D:\Projects IDE\Visual Studio\MyWork\Websites\SellCars\SellCars\App_Data\SellCars.ldf’ does not match the primary file. It may be from a different database or the log may have been rebuilt previously

This is my connection string:

 <add name="CarsEntities" 
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename='D:\Projects IDE\Visual Studio\MyWork\Websites\SellCars\SellCars\App_Data\SellCars.mdf';Initial Catalog=SellCars;Integrated Security=True;User Instance=True" 
      providerName="System.Data.SqlClient" />

I do not try to change anything inside of the database not even add any data but I still get these errors.

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:01:46+00:00Added an answer on June 16, 2026 at 9:01 pm

    Add Aly-PC\Aly to the active directory users who can access the SQL server. Then add the SQL server login you just created to the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a database using entity framework code first and I'm having some issues
I'm using Entity Framework Code First. The class i'm trying to create contains two
Okay, I seem to be having a problem. I'm trying to create a twicker
i having problem in converting this C# code into VB.net. The loadLecturer seem to
I seem to be having a problem. I want to write some code that
I seem to be having a problem with the NSMutableArray. Here's my code: NSMutableArray
I seem to be having a problem with a preg_match code, I am trying
I seem to be having a problem removing the image in UIScrollView. I was
I seem to be having a problem checking if a string exists in my
I seem to be having a problem with checking for list equality. In my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.