0

I started an application using Entity Framework Code First. In my Web.config I added the connection string:

<add name="MyContext" connectionString="Data Source=server\mssqlserver2008;Initial Catalog=dbname;persist security info=True; Integrated Security=SSPI" providerName="System.Data.SqlClient" /> 

And I received a error when I tried to access my Controller: CREATE DATABASE permission denied in database 'master'

So, I debugged the code and I found that the attribute "ConnectionString" inside my Context it's different from my Web.config:

Data Source=.\\SQLEXPRESS;Initial Catalog=MyProject.Models.MyContext;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFrameworkMUE 

Why the ConnectionString is wrong??

1

1 Answer 1

3

In your EF initialization code, make sure you specify the connection string name like this

public class MyDbContext : DbContext { public MyDbContext() : base("MyContext") {} } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.