asp.net mvc - Connection string EF Code First -
i started application using entity framework code first. in web.config added 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 received error when tried access controller: create database permission denied in database 'master'
so, debugged code , found attribute "connectionstring" inside context it's different web.config:
data source=.\\sqlexpress;initial catalog=myproject.models.mycontext;integrated security=true;multipleactiveresultsets=true;application name=entityframeworkmue
why connectionstring wrong??
in ef initialization code, make sure specify connection string name this
public class mydbcontext : dbcontext { public mydbcontext() : base("mycontext") {} }
Comments
Post a Comment