I'm currently working on a little project where i need a bit of help or an advice.
Little Background Infos:
I have 3 database Tables.
Database A has a number of questions and all of them have a UUID which relates to Database B.
Database B just has a UUID which references to the Questions in Database A.
Database C has a one-to-one relation with Database B so it also has the UUID of Database B.
I am filling Database A and B with Postman. So I upload a CSV File which has a number of Questions. These Questions are all being saved in Database A and the upload automatically generates a Row in Database B with the UUID.
Now, when the User starts the Application, the Backend should generate a Row in Database C which references to Database B.
My Problem is, that I have no idea, how to retrieve the UUID from Database B, to save it as a reference in Database C. I have read something about doing a Response and saving the UUID from Database B in the URL so I can later use it, but I have found nothing on how to do this properly.
Can someone provide me a Link to a Documentation where I can find something on how to do it?
Thank you! :)
Related
I am using the Microsoft.AspNetCore.Identity.EntityFramework in my Blazor Server Project and have customized it with no problem. I do enjoy the simplicity and robustness of the Identity; however, since I am developing for deployment, I came across a small problem. In the disaster recovery, the FULL restore from an MSSQL backup works without a hitch. This type of backup is crucial if you have not changed anything in your ApplicationDbContext for the deployed Blazor Server Project. So for that matter in disaster recovery to a same state and DbContext, there is no issue, but should you have a small change from one install to another in the DbContext, or say you are upgrading the previous version of the Blazor Server Project with changes in the context, you cannot recover the users since you can only do a complete FULL restore with the previous DbContext as the Db Schema and Design.
How can I restore, or better yet, migrate the date from one instance of the DBContext to another? I tried doing a data restore from backup device, but it does not let me do the restore due to the foreign key between the user table and the user claims and user roles tables. Foreign key constraints do not permit me to restore the users with the previous generated GUID which contain vital information link to other data. Say for example one table tracks events that are created by the user, if I re-create the user, it has different GUID than what is registered in the backup.
Any help will be appreciated.
If you query the table for the ASPNetUsers you get the following:
Id UserName NormalizedUserName Email NormalizedEmail EmailConfirmed PasswordHash SecurityStamp ConcurrencyStamp PhoneNumber PhoneNumberConfirmed TwoFactorEnabled LockoutEnd LockoutEnabled AccessFailedCount
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------- ---------------- ---------------------------------- -------------- -----------------
6cd26b55-b0c6-41ae-ac6c-ff9ae3242c3b userone#mymail.com USERONE#MYMAIL.COM userone#mymail.com USERONE#MYMAIL.COM 1 AQAAAAEAACcQAAAAECp/NfxxEWw8fbd0jIrXOGZ/v/ggPscxMIINueP2dUQAihgRwrE1a+t1os/7MwvPCg== OJP4HUHN6FNCXHXETVJTDQLC6RBUCLJS f69a0ff7-9298-4d1f-8faa-e8ab3db3ab70 NULL 0 0 NULL 1 0
9eda9ba1-dd47-4308-ba62-a19381a32d56 usertwo#mymail.com USERTWO#MYMAIL.COM usertwo#mymail.com USERTWO#MYMAIL.COM 1 AQAAAAEAACcQAAAAEFcXpQREt8sfhssYHlH/hRSlk3yX/bGMCYpXpTrid+YLNMFkDr5V45MnIo0JOPmWlw== YLZJSYILLPQZBFGCOJLXKFZB64YXCHIK c389b663-fcd1-4918-b9ed-54bc583666cc NULL 0 0 NULL 1 0
(2 rows affected)
Completion time: 2021-08-06T14:19:46.8143727-07:00
Since the Id is a GUID generated by the EF Core Identity Table, and is linked to the other ASPNetCore tables such as UserRoles, UserClaims, Etc., how can I import user data with the old GUID that was previously generated?
Edit Aug 12 2021
I have found a temporary work-around for the problem. For purpose of explanation I will use APP, OriginalDB, BackedUpDevice (the bak file) and RestoredDB and NewDB.
The OriginalDB I am continuing to work on the model and ASP.Net Core/Blazor application (APP), therefore on ocassions the model changes. I have my App that when it initializes for the first time, it uses the models to create the Database on the server, should it not exist. I use migrations to create the new model to be put on the server at first run. ASP.Net Core Identity facilitates this.
So, the original problem arises only when the model is modified in the APP and the APP needs to re-apply the migration. I don't use subsequent migrations since, once the OriginalDB is in use, there is data and even if the model changes, the data will need to be copied. I have absolutely no problem with this. I can restore from the BackedUpDevice to another Database as the RestoredDB. I then use the RestoredDB to insert the data back into the NewDB, which is a freshly created copy of the OriginalDB schema and the model changes in the APP. Thus, this gives me my data, but I cannot use this method for the ASP.Net Core Identity tables since it uses Foreign Keys.
The work-around that I have found, is that I can safely delete the ASP.Net Core Identity tables, namely AspNetRoles, AspNetUserClaims, AspNetUserLogins, AspNetUserRoles, AspNetUsers, and do a copy schema and table from the RestoredDB to the NewDB. While recreating the tables using this method works, I have the problem that I have also modified these user tables, not only changing the table names, but also adding custom fields as shown primarily in This Article, on future iterations of the APP, there may be additional custom fields and/or changes that affect these tables. Hence why I need to see how I may just copy the RestoreDB user tables data, including the generated GUID for the user with Foreign Keys to the NewDB user tables. Any suggestion will be greatly appreciated.
I obviously don't know everything about your situation, and I don't understand some parts of your explanation at all, but the approach you've outlined is going very far down the wrong road.
EF Core 5.0 migrations allow a lot flexibility in how they are created, maintained, and applied. You should leverage these features to accomplish what you want to do, rather than creating new databases and copying data into them.
Some examples that seem to be applicable to your use case:
From Using a Separate Migrations Project, you may want to consider having two different sets of migrations - one for local development / iteration, and one that just has migrations that take the released application from one version to the next
From Customize migration code, solving your problems with the automated migrations may involve customizing the automatically generated migration code. Or creating empty migrations and writing completely custom code to perform intermediate data migrations steps
From Excluding parts of your model, you may need to exclude certain objects in one DbContext from being included in the migrations for another DbContext (for instance, if your Identity tables are coming from a different DbContext than the rest of your app tables, but you reference the Identity entities in your main app's DbContext)
I have access to an Oracle Database and plan on manipulating the data however, I don't want to affect the database itself. So I am wondering if it is possible to create a new database from the main one that can update itself with new data whenever the main database changes while not affecting the main database? (asynchronous replication?)
Not looking for exact code but key words or topics that I should read to find out more information. Sorry I just don't know where to really start.
Not looking to make a simple copy of an Oracle Database because that data will become stale as soon as new data is uploaded to the original database.
e.g. Database 1 has employee records. I want to clone this database and call it database 2 while also making sure that anytime database 1 changes, so does database 2 but not vice versa.
I have one database. I want to transfer data from one database to new database. all tables have same fields into both databases. I can use export feature of openerp, but I need to maintain the relationship between odoo table and there is so many tables so I don't know which tables I can import first into a new database so it does not give any problem into other tables data import.
is there any that I can do this into easy and simple way?
There are two ways in which you can take backup.
By hitting the given URL – server/web/database/manager.
By Import/Export and validation, functionality is given by Odoo.
• Backup-> We can take the full backup of the system and store zip file in our system for a future update. For that, we have to hit this URL- http://localhost:8069/web/database/manager
- Restore-> In a similar manner, we can restore the database by uploading the zipped file which we recently downloaded.
There are 2 Oracle databases with the same tables on two different servers. Database A on server A and Database B on server B
A: Table1,Table2
B: Table1,Table2
These tables are identical to each other, in that it's possible to copy the data tables from server A to server B. We only have remote access to the database on Server A, but full admin access to Server B.
So, database A is remote and has a primary and secondary DB. The secondary DB gets updated with the latest data, then we must switch the DB we're pointing to towards secondary. Same for the opposite, when things are pointing to secondary, primary DB will get updated with data, then the system should point to Database A primary. This way the database is never down we just switch what we point to after the other one gets updated.
There is also a web interface that sets a config file whether we're pointing to the primary or the secondary DB
Now, I'm trying to come up with solutions on how to get/synchronize/copy/point to the correct database to get the updated data either directly from A or by copying data A to B.
Solution 1) We read db config file and point directly to the primary (or secondary) DB
Solution 2) Build a windows service that will detect when primary or secondary DB gets updated, and copy tables from DataBase A to DataBase B.
Solution 3) Have a "copy tables" button on the web interface that will start a background task of copying data from A to B using http://hangfire.io
Solution 4) ??
So far, I like the idea of solution 1 the best, where we just point directly to either the primary or secondary DB based on configuration. This idea doesn't involve any copying to the identical tables on Server B.
However, I was wondering if there is any other possible solution? Would triggers, replication, or something else work here?
Thanks.
I am creating an application in Microsoft Access. This is for a small database that the customer will run on a desktop. No network of any kind will be involved. All the necessary files to use the database must be on a single desktop computer.
I want to deliver the app to my customer in stages. Most likely I will email the .accdb file to the customer. How do I deliver an update and maintain any data already entered by the customer? Updates may include changes to the table structure as well as to forms.
The answers given to my original question address the issue of changing forms and other UI elements. However, what if I want to add a table or add column to an existing one? How do I seamlessly deliver such changes while preserving as much data as possible on the user's end?
Split the database and the interface into separate files. Google should have plenty of information as this is typical for MS Access apps.
Here are a few resources to get you started:
How to manually split a Access database in Microsoft Access
Splitting an Access Database, Step by Step
You absolutely MUST (!) split your database into two parts. A backend part storing the tables ("the database") and a frontend containing the forms, reports, queries and application logic ("the application"). Link the tables from the backend to the fontend.
The frontend might also contain tables with control paramameters, report dictionaries etc., but no data that your customer enters!
Newer versions of Access have a database splitting wizard.
You might need a code that automatically links the backend to the fontend on the customers site.
UPDATE
You have two possibilities to alter the schema of your database on the customers PC.
1) Do the Updates through the DAO (or ADOX) object models. e.g.
Set tdf = db.CreateTableDef("tblNew")
tdf.Fields.Append tdf.CreateField("fieldname", dbText)
...
db.TableDefs.Append tdf
2) Use DDL queries
CREATE TABLE MyNewTable (
ID AUTOINCREMENT,
Textfield TEXT(50),
LongField LONG,
...,
CONSTRAINT PK_MyNewTable PRIMARY KEY (ID)
)
Or
ALTER TABLE SomeExistingTable ADD COLUMN Newcolumn Text(50)