0
votes

I created a mvc4 website with connecting a database. The database is also use by another application. So, I don't recreate the database when I deploy the mvc4 website.

connectionString="metadata=res:///Models.Qcgl.csdl|res:///Models.Qcgl.ssdl|res://*/Models.Qcgl.msl; provider=System.Data.SqlClient;provider connection string=" data source=.\SQLEXPRESS;Trusted_Connection=yes; attachdbfilename=D:\xxx.mdf;integrated security=True; connect timeout=30;multipleactiveresultsets=True;App=EntityFramework""

The error is

CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file xxx.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

1
Are you using EntityFramework codefirst approach ?Razack
No, I used a existing database to create a model.Anubis

1 Answers

0
votes

Try below connection string

<add name="ContextName" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=YourDBName;Persist Security Info=True;User ID=YorUserid;Password=YourPassword Trusted_Connection=yes;integrated security=True;connect timeout=30;multipleactiveresultsets=True;
        providerName="System.Data.SqlClient" />