Prevent docrine from updating schema on one database - sql-server

I have a Symfony project using a MYSQL database. I setup a second entity manager which accesses a SQL Server database. I'd like the ability for Doctrine to read and write to both databases, which it can do now. But I'd like to prevent Doctrine from updating the database schema, if I were to make a change like that by myself.
Doctrine should not be able to add tables, remove columns, or change the name of columns in the SQL Server database. Doing so would break the legacy application that uses this database.
Is there some setting I can use to make sure the database schema won't change?

Related

How can two SQL databases be merged into one database?

I have 2 SQL Server databases. The reason is because I created an ASP.NET MVC project using "Individual User Accounts" for authentication. This created a default connection with a database that includes the following tables:
AspNetUserClaims, AspNetUserLogins, AspNetUsers, _MigrationHistory
I then went a step further and built out my own custom roles with a RoleController. So I also have a table for AspNetRoles and AspNetUserRoles. Everything with this is working.
I also have another database that I built in Management Studio that is holding all of the data of my application. I am using Entity Framework to communicate with the database.
I currently reference both databases in my web.config connection strings.
But I would like to migrate the database from the default connection (with my AspNetUsers) into the one in Management Studio.
Is it as simple as copying the tables and putting them in my other database in Management Studio or can I copy the whole schema? Just trying to figure out the best approach here.
You can migrate tables from a database to a diferent one. On SSMS, just right click on a database, select Tasks -> Generate Scripts, and use the wizard to create a script with the table definition and data (optional) to be executed on the new database.

Azure sql cross database trigger

. I have two databases in same azure sql server .i want that both database interact to each other using trigger. i.e If any record is inserted in Customer table of first database the trigger gets fired and record is inserted in another database.
We had / have the same problem with triggers that we use for insert-update-delete where we write a record to Database-1 that has the primary table, but also updates Database-2 where we hold "archive" versions of the tables.
The only solution we have identified and are testing is to bring all of the tables into a single database and separate the different tables under separate database schemas in the one database.
Analysis so far of this approach looks promising.
I think what you're trying to do is not allowed in Sql Azure. From my expertise what you are trying to do is a bad practice on-premise as well (think backups-restore and availability issue scenarios).
You should move the dependency in the application and have the application update both databases, as appropriate.
Anyway, if you want to continue with this approach please take a look over Elastic Query feature: https://learn.microsoft.com/en-in/azure/sql-database/sql-database-elastic-query-overview
Please let me know if I can help with something

How can I store SQL Server Database Metadata for Sync Framework in a different database on the same server?

I would like to be able to store the tracking tables in a different database the original. For a couple of reasons.
I would like to be able to drop it on demand if I change versions of my application.
I would like to have multiple sync scopes separated by user permissioning.
I am sure through the sqlmetadatastore class there is a way, but I have not found it yet.
the sqlmetaadatastore will not help you in any way with what you're trying to achieve. am pretty sure its not in anyway exposed in the database sync providers you're using.
note that the tracking tables are not the only objects Sync Framework provisioning creates, you will have triggers, tracking tables, stored procedures and user defined table types. and you're not supposed to be dropping them separately or even dropping them by yourself, but you should be using the deprovisioning API.
now if you really want to have the tracking tables on a separate db, the provisioning API has a Script method that can generate the SQL statements required to create the Sync Fx objects.
you can alter that to create the tracking tables on another DB, but you have to alter the triggers as well to insert on this other database.

How to change existing database schema according to new changes in new schema in sql server using c#?

I am using SQL Server 2008 R2 with asp.net MVC.
Scenario is, I am having the License generation application. Where as a each while creating the new license has it creates a separate database according to centralized database script. Say DBCentralized is the current central database and after creating 3 licenses DBLicence1, DBLicence2, DBLicence3 are three databases. This architecture may not good but client's architects want to follow this. But say I am having any schema wise changes in DBCentralized database. Say adding new table, stored procedure, or altering table then certainly this will reflects onward license creations. But what about the existing databases. I need to update existing database schema according to new alterations. since this scenario in short is Updating existing licenses.

MVC Membership database to SQL Server 2008

When I create a new MVC application with EF, it creates all the views, models, controllers and logic for users to be able to log in, change passwords etc. The data is held in a MDF file in the app_data directory.
I used this for my users, and then had my own SQL Server 2008 database which was created code first using EF for all my other tables. When I wanted to reference a user from a table within this database, I used the ApplicationUser.Id.
Doing it this way, I have not got a foreign key between the table that holds the users and any other table in my custom DB, but thats a different topic.
The question I have, is how I can I stop this happening every time I create a new application, and how do I fix the issue I have now.
I have two different databases, when I just need one. have one database in SQL Server (which is what I want) and one in a file which I cannot convert to SQL Server as it was created in 2012, and I am using 2008 SQL Server.
I am wanting to now deploy this on a server where all data is read from SQL Server.
The way I see it, I need to somehow get all the tables it creates for Membership, and put them into the database I created, then change the connection string. However first off I don't know how I would do this, and second... WHY do I have to do this? How can I just have one database next time. Am I missing something?
After some research and messing around, I have answered my own question and think it may be useful for others.
I am using MVC 5 with the default ASP.NET Identity for my users.
What I found is that if I changed the connection string to point to my SQL server, it will create the database for me (the one that was previously a file in my app directory).
I then added a connection string to the same database for the context I created and it created all the tables for that in the same database.
The result is that I have one database with all my tables in.

Resources