Mocha
Mocha

Reputation: 2253

Invalid value for key attachdbfilename C# Identity Server Connection String

I am trying to create the identity tables in my server database. However, I keep getting an "Invalid value for key 'attachdbfilename'" error.

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=den1.mssql.gear.host;Initial Catalog=groceryapp;User Id=appID;Password=password;AttachDbFilename=|DataDirectory|\UsersDB.mdf;" 
         providerName="System.Data.SqlClient" />
    <add name="appID" 
         connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=den1.mssql.gear.host;initial catalog=groceryapp;user id=appID;password=password;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" /> 
</connectionStrings>

I am following the tutorial of this video.. https://www.youtube.com/watch?v=Y02ccL4-_K4

EDIT

I changed the |DataDirectory| to my physical path, but now I get permission issues with SQL Server:

ExceptionMessage=CREATE DATABASE permission denied in database 'master'. Cannot attach the file 'PHYSICAL_PATH\App_Data\UsersDB.mdf' as database 'testDatabase'.

Upvotes: 0

Views: 128

Answers (1)

Jeric Cruz
Jeric Cruz

Reputation: 1909

First:

You can try to change that with the physical path of your Users.mdf

Second:

Try to check if user appID has a right create table. If not, give it privilege to create one.

Upvotes: 1

Related Questions