2

I am trying to create a database for an MVC 4 application. I used Entity Framework Code first approach. After digging into the problem I realized that it was not a connection string issue. I downloaded Sql Server Data tools and tried to create it from there but I get the same exact error which is related to Windows Authentication. I am not sure what is causing this problem, I even tried running as admin.

Any ideas??

enter image description here

I have tried mostly all forms of connections strings available online, the last two that I tried were

 <add name="Request" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=Requests;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Requests.mdf" providerName="System.Data.SqlClient" />
 <!--<add name="RequestsContext" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\Requests.mdf" /> -->

I am trying to create a local database, I have asked a question about entity frame work right here thinking that the problem was from there but now I know it has nothing to do with it. Here you can see all of the details about the models I created and I am trying to generate the database from.

Using Entity framework with SQL Server 2012 (local *.mdf database)

Community
  • 1
  • 1
laitha0
  • 4,148
  • 11
  • 33
  • 49
  • 2
    Is the SQL Server service running? – Raj More Jul 30 '13 at 14:51
  • Are you trying to connect to a local or remote server? Could you provide the entire line from your config file that has the connection string in, including all the EF bits? Obviously take any sensitive information out =] – Sean Airey Jul 30 '13 at 14:51
  • Is sql server installed? – OzrenTkalcecKrznaric Jul 30 '13 at 14:55
  • please see the edit for more info, I looked at teh services, there is a a service called SQL Server VSS Writer and this is running. I installed Visual Studio Ultimate and I think it comes with it?? correct me if I'm wrong – laitha0 Jul 30 '13 at 14:58
  • Did you solve it using any of the solutions? – OzrenTkalcecKrznaric Jul 31 '13 at 12:18
  • I solved it for *.sdf databases but still cannot create an *.mdf one. I am trying with it again in a different project since I messed around with a lot of the existing project's properties – laitha0 Jul 31 '13 at 15:05

2 Answers2

2

You don't have SQL Server installed on your PC. Install Express Edition and you should be fine.

EDIT: Use connection string for local server:

<add name="Request" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=Request;Integrated Security=True;" />
OzrenTkalcecKrznaric
  • 5,535
  • 4
  • 34
  • 57
  • I just did, "SQL Server (SQLEXPRESS)" service is running, but "SQL Server Agent (SQLEXPRESS)" is not. I cannot enable this one as the options are greyed out. and the problem still exists. – laitha0 Jul 30 '13 at 15:34
  • I don't see why would you need SQL Server Agent? This is not an SQL Server Express Edition feature, it's used for e.g. running database jobs and such. – OzrenTkalcecKrznaric Jul 30 '13 at 15:44
  • I probably don't need it but I still have authentication problem. How do you configure SQLEXPRESS to use Windows Authentication? – laitha0 Jul 30 '13 at 15:47
  • It should always include windows authentication. See updated answer. – OzrenTkalcecKrznaric Jul 30 '13 at 15:54
  • I would still recommend installing LocalDB for development though, it's simply more appropriate (and no need to manually manage the Windows Service anymore). If you don't need to simulate traffic to an external SQL Server process, then CE (Compact Edition) is even easier. – tne Jul 30 '13 at 20:40
  • 1
    If you have "SQL SERVER (SQLEXPRESS)" as a service name, then the local instance name is "SQLEXPRESS", which you can explicitly name in your connection string: ``` – tommy_o Jul 30 '13 at 23:16
  • @tommy_o: you're right, I have a no-brainer-copy-paste-error :P; updating my answer – OzrenTkalcecKrznaric Jul 31 '13 at 04:33
1

If its local, probably SQL Server service is not running. Start>cmd and services.msc will open services page. Right click on sql server and start

Kuzgun
  • 4,649
  • 4
  • 34
  • 48
  • I think its running, is it SQL Server VSS Writer? I installed VS 2012, and SQL server came with it. I tried to install it manually but I get an error when I installed it is also related to Windows Authentication – laitha0 Jul 30 '13 at 15:00
  • thats one of them, there should be more – Kuzgun Jul 30 '13 at 15:02
  • that's the only one I have. I can't manually install SQL Server – laitha0 Jul 30 '13 at 15:03