Entity Framework update-database prefixes tables - visual-studio

I am running the update-database command in VS to create tables in a DB for a project developed by someone else. For some reason, when i run the command, all the tables are prefixed with my domain\username. The same also happens for one of my collegues, meaning we now have two sets of tables! Any idea how we stop this happening?

This happens on when you are not a database owner and the object names are not schema-qualified. So either run the migration as a database owner, or specify a schema in the model configuration to force all the objects into the dbo schema.

Related

Why do I have to disable Javers' schema management in order to initialize my application?

In my Spring-Boot project when:
javers.sqlSchemaManagementEnabled=true
The Javers tables are created on the first execution (when the tables do not exist on the database) and the code runs as expected, however from the second execution onwards an exception is thrown describing that the tables cannot be created because them already exist. This is the situation that I cannot understand, isn't Javers supposed to know that the tables already exist and do not attempt to create the tables?
javers.sqlSchemaManagementEnabled=false
If the tables where already created on the database, manually or executing the application with this option as 'true' at least once, the application executes as expected.
What am I supposed to do?
Is there something wrong with my Spring-Boot configuration? The application was supposed to run with 'sqlSchemaManagementEnabled=true' even with the tables already created?
I expected is to leave the 'sqlSchemaManagementEnabled=false' and create the tables manually?
I had the same problem, when using other than public schema in PostgreSQL.
I solved it by switching to public schema, now it works correctly with javers.sqlSchemaManagementEnabled=true.
For other schemas, you should somehow specify the schema name in org.javers.repository.sql.schema.TableNameProvider
If javers.sqlSchemaManagementEnabled=true, Javers creates SQL tables if they do not exists already.
It's checked here:
https://github.com/javers/javers/blob/master/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/JaversSchemaManager.java#L215
It's hard to say why it doesn't work in your case, try to debug this code using the latest Javers version.

Public synonyms issue with two schemas on same instance

The database I am using is Oracle 11g Express Edition release 2.
I created 2 schemas in the same instance xe. They all have the same tables names and sequences names and stored procedures and stored functions and views names. But the tables structures and views texts are different ( there is some modifications between them ).
The reason for the creation of these two schemas is because our project has two versions. So the first schema is used for the first version , and the second schema was created for the second version. The mechanism of our web application Spring project is that whenever a connection is made through the web application login page then a corresponding Oracle user is making a connection according to the login entered ; so there is no fixed credential connection , there are Oracle users corresponding to each web application login.
So in order for each user to work with each database objects then I created public synonyms for every objects , and granted permissions to them for each user. But the database objects are owned by the schema I mentioned at the beginning. Now my problem is this : our customer wants the two project versions to be run on a same instance ( same computer server ). So one of the project version cannot run because the public synonyms can only refer to a particular schema owner. So how to make the public synonyms work for each schema ?
In short, you can't. However, you can always use a distinct synonym name to identify the object.
Something similar to below:
create public synonym structures_v1 for schema1.structures;
create public synonym structures_v2 for schema2.structures;
Oracle provides 2 totally different technologies for this situation (which comes to my mind):
Editions (and Edition Based Redefinition)
PDBs
With Editions you can create the same Object once in each Edition - but there are limitations like tables are not editionable.
It's not a feature you just enable, you need to understand the concept and implement it properly.
PDBs enable consolidation of Databases with colliding namespace (such as your described synonyms) within the same CDB and therefore save SGA/memory. Basically they are totally separated - limited interference can be implemented when it's concept of object & data inheritance is understand.
What about creating a 3rd Schema and having Synonym and permission to query 1st and 2nd schema. Anyone tested this concept?

build schema for specific tables in database using doctrine?

In my symfony project i need to generate schema from specific tables not all database tables ,so please tell the way to do if it is possible?
If you use the command build-schema you can generate a schema from the database that is configured for the project. The schema.yml in the config folder should contain all the tables, and you can delete the tables you do not need, and then use the commands build-model, build-form, and build-filters in order to create the classes for the remaining tables. This way, there will only be classes for the tables that you want.
Hope this helps!

"Update Model From Database" does not work in .edmx Entities file. My Database is DB2

I am trying to reflect new changes or add a new table to my model in EDMX file using 'Update Model From Database.' Then i get this error message in Update Wizard saying "Error retrieving Database information. An Item with the same key has already been added."
I am using DB2 database and VS 2010.
Please let me know how i can add a new table or reflect the changes to my model with the changes made to the database. Right now i am deleting the entire model and recreating the new one.
Any help is appreciated.
I was getting this same error. In my case with DB2 9.5 LUW the solution was to remove duplicate named stored procedures on the server. DB2 lets you have multiple stored procs with the same name but different definitions (ie different parameters). But apparently this isn't compatible with Entity Framework. Fortunately for me the duplicates were actually unused old versions.
An alternative is to edit your EDM file in XML editor mode.
I have followed the solution provided by vikrantislav. And in addition to that, I made one more change. By default EF tool brings objects from all the exiting schemas. So make sure you don't have duplicate store procedures in any of those schemas or change the connection properties to filter out by a specific schema. In my case I have filtered out by specific schema as I don't want to mess up with someone else's store procedures in other schemas. And now "update model from database" wizard started working. what a relief.
Schema filter in connection properties window

Change Oracle Schema at runtime when using SubSonic

In my project, I am using Oracle Database and SubSonic for DAL. I have a problem with SubSonic and Oracle Schema, that is:
When developing, I used a schema DEV in Oracle Database and generate DAL using SubSonic.
After that when release to customer, he used a new schema TEST in Oracle Database and changed the connection string in app.config to connect to Oracle. The error will appear, that is “Table or View does not exist”. I found this error and see that the schema of tables is still DEV.
I do not want re-generate DAL after change schema and when released to the customer. Please help me.
Firstly, your schema should not be DEV. DEV is a user or role.
Your schema name should be related to the data content (eg ACCOUNTS or SALES)
Secondly, consider whether you or the customer is going to decide the schema name. Say you have a product called FLINTSTONE. You may decide that the schema name should be FLINTSTONE. However your customer may want to run two instances of your product (eg one for local sales, the other for international) and use the same database. So they want FS_LOCAL and FS_INTER as the schema names. Is that option a feature of your product ?
Next, decide if your application should connect as the schema owner. There are good security reasons for NOT doing that. For example, the schema owner has privileges to drop tables, which is generally something the application doesn't do and thus, on the principle of least privilege, is something your application shouldn't have privileges to do.
Generally I would recommend some config parameter for the application for the schema name, and after connecting to the database, the app should do an "ALTER SESSION SET CURRENT_SCHEMA = 'whatever was it the config file'". The application database user would need the appropriate insert/update/delete/select/execute privileges on the objects in the application schema. If the application can't do that, you can have a LOGON trigger in the database.
Gary is correct in not using DEV as a schema on your own machine. In using Oracle we typically set up the schema as what the client is going to name their schema. This however does not fix your issue. What you need to do is create a global alias in Oracle that maps say DEV to CLIENTSCHEMA. You should still rename the schema on your machine but this will allow your schema to differ from your clients.

Resources