localdb readonly database problems - localdb

enviroment
visualStudio 2012
localdb v11
a solution with 3 projects on it:
1st class library with an ORM database model, and a local db Localdb.mdf inside App_Data directory.
2nd is a web project that uses this database model.
and 3rd a c# console project that uses this localdb database, referencing the 1st class library, and having at the app.config a localdb connection string defined as:
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:_work_desarrollo\Apps\Business\OpenAccessAppsModel\App_Data\LocalDb.mdf;Integrated Security=True
My problems are:
i would like to made some changes using VS 2012 server explorer to this database like deleting tables and i got "The database is readonly. Updates to the database will not succeed until the database is made read write"
and second, how can i made available to the console application (the 3rd project) the database file so i can copy/paste the release folder to "install" the console application?
How the database connection should be modified to have the database locally with the console applciation? (same directory as the app)
Thanks a lot

Happened to me today.
You can grant/change db permissions like this:
icacls mydabase*.* /grant "NT Service\MSSQL$SQLEXPRESS":(F)
icacls mydabase*.* /grant "MYMACHINENAME\Administrator":(F)
I already had sqlexpress permissions set but found out that machine\administrator was also needed.
Hope it helps.

Please check atribute of .mdf and .ldf files and the container folder.
Check this answer as well.
I've done these two things and Presto! It Works!

The problem is only file .mdf and .log permissions over the user or application execution. Only give the security permission read and write in the file properties and the connection string for example "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\WinApps17\Cash\Invoices\Data\VFindx.mdf;Integrated Security=True;Connect Timeout=30"

Related

EF Core migration to remote database

I have a working app and database locally. I want to setup a remote database for the remote application.
I thought forcing the environment variable would to it:
dotnet ef database update -- --environment Production
But it says "...The database is already up to date." Checking the remote database, it's still empty.
Now, the appsettings.json and appsettings.Development.json files appear to be working correctly. I confirmed my local application connects to my local database, and my remote application connects to my remote database.
Given that the connection strings are correct in the settings, how do I tell EF to do the thing again but for the other database? I feel like I'm missing something obvious.
So I was just using the wrong environment declaration. Run this before the update:
$env:ASPNETCORE_ENVIRONMENT = 'Production'

How to backup postgres db hosted on cloud with pgadmin4?

I'm hosting my db using AWS RDS and I'm trying to backup tables. However once it's finished backing up, where is the downloaded on my computer?
Doesn't seem like theres a path to save the file
I've checked a couple of answers and others are having same issue
https://stackoverflow.com/a/29246636/11110509
The "Filename" element in that dialog box lets you pick a directory as well as file name. That is where it is. If you just typed in a filename without giving a path, then on Windows it is probably in your user's "Documents" folder.

localdb does not create database file if its missing

I use this connection-string:
Server=(localdb)\\MyInstance;Timeout=30;Database=MyDB;AttachDBFilename="C:\Temp\MyDB.mdf";Trusted_Connection=True;
Once I run a migration from my code using
dbContext.Database.Migrate();
Normally, this "simply" works. The db is not just migrated, it is also getting its file created for it.
However, on the device of a colleague, the same code results in this error message:
System.Data.SqlClient.SqlException: "Cannot attach the file 'C:\Temp\MyDB.mdf' as database 'MyDB'."
If I give my database files to my colleague and he places them in the appropiate directory first, everything works as expected and the other code in that program can access everything in it, as it would do normally.
We've tried different paths and always checked the file-system rights. LocalDB or entity-framework (I'm not sure which is normally responsible for creating database files) simply won't create the database-file if it's missing on his device.
Are there any switches causing this? Can I explicitly tell localdb with the connection-string that it should create the database file?

Change path of Firebird Secondary database files

I have created a Firebird multi-file database
Main Database file D:\Database\MainDB.fdb
Secondary files (240 Files) located under D:\Database\DBFiles\Data001.fdb to D:\Database\DBFiles\Data240.fdb
When copy database to another location and trying to open it Firebird doesn't locate the files if they are not in D:\ partition
I want Firebird to locate the secondary files under Database\DBFiels folder at the new path.
So if I copy the database to C:\Database\MainDB.fdb
Firebird would open Data001.fdb in new path like C:\Database\DBFiles instead of old path in D:\Database\DBFiles where they were initially created
Can that be done with Firebird? if not, then how it should be done?
Update:
Finally I found out it's not possiable to change Firebird database secondary files usign Firebird.
but I found this Firebird FAQ mention GLINK tool but It doesn't support Firebird 3.x so I didn't test it, and It's not recommended to use it even with supported versions of Firebird.
Done what exactly?
UPD. I edited the very vague original question to make clear WHAT the topic starter wants.
You can not reliably "copy files with Firebird" - Firebird is not files copying tool. You can to a degree use EXTERNAL TABLE for raw files access, but very limited and not upon the database itself.
It is dangerous practice to "copy databases" while Firebird is working, because you would only copy part of the data. The recently updated data that is in memory cache but did not yet made it on disk would be lost. The database file would be inconsistent with some data updated and some not yet. When you "copy database files" you have first to shutdown either those databases or even the whole Firebird server.
Firebird has it's own tools for moving databases around - and those are called backup/restore tools. Maybe what you need is nbackup tool, if gbak is too slow for you.
Finally, you can list files that comprise the database. You can do it via gstat utility or via "Services API" it uses. You also can select from RDB$FILES system table. However what would you do after you did it? The very access to the database makes it badly suited for consequent copying (#2). You would perhaps need to shutdown database, turn it to read-only AND single-user state, and only then attach to it and read RDB$FILES. And after copying done - you would have to de-shutdown the database. Kinda much more complex than nbackup.
https://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/gstat-example-header.html
https://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/gfix-dbstartstop.html
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref-appx04-files.html
https://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/gbak.html
https://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/nbackup.html

Connecting to localDB in Rider gives the wrong DB

https://blog.jetbrains.com/datagrip/2016/10/07/connecting-datagrip-to-sql-server-express-localdb/
The description above worked fine. But the opened DB contains system tables like spt_monitor, spt_fallback_dev. (sqllocaldb.exe i showed only one localdb)
I have an mdf file which contains the DB I want to use. Any idea? (I tried to give the full name of the mdf file in the uppermost Database field, but it did not help)
One more info: In visual studio sql server object explorer, I see the system databases and the mdf files as well. In vs / server explorer I can connect to the mdf file.
I found the solution:
after giving username and password go to schema tab
(exit from visual studio)
check the mdf file, check the relevent schema, e.g. dbo
if you missed this step then database double click on "connection / schemas" to make the check