Entity Framework on different database - sql-server

I have a project which uses entity framework.
We map a mssql db with entity framework. Now we want to change mssql db to oracle db. But I don't want to change my model of db in entity framework. Two dbs are same tables columns etc.
only difference is their technologies(mssql and oracle) and some of the column data types.In mssql we use bigint instead of number in oracle. Is it possible to use same model with difference dbs which have same tables on Entity framework?

The provider model with EF allows support for a variety of databases. I believe this includes oracle however I haven't ever used it personally.
I can tell you that when switching between database providers the connection string is normally the only change required. The only time i think you would have to change anything at all in your database is if the provider didn't support a specific operation you are using.

Related

Entities with relationships transfering via serialization problem - different IDs Entity Framework Core , SQL

I am using EF core and SQL database in my project. I have data model with several entities (principal with child/dependent ones) and as key I used int IDs. My entities have also defined unique UUID property for other usage. One of the is to identify same entity in test/production environment because primary key is not consistent. That means entity on test server ID=1 is not the same entity on other SQL server with production environment.
I thought using INT ID would be a good performance choice BUT I came to a problem:
I am in need to transfer selected data (entities) from test to production SQL server. My idea was to serialize those entities to JSON via .NET core native serializer from test machine and loading them to production one.
I am able to identify individual entities between enviroments via UUID property, but the problem is with setting relations/navigation between them. Have anyone solved similar issues?

Prevent docrine from updating schema on one database

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?

Do i need to define relationship in SQL Server database if i am using EF and Linq

I am working on a asp.net mvc project and using Linq for all my data related operations. In such cases, do I need to define relationship in the SQL Server database ??
I am using Entity framework and Linq so I think it doesn't matter if I create an E-R diagram(i.e defining relationship) or not.
By 'define relationship' I assume you mean 'Foreign key constraints'. It is always advisable to define constraints in order to maintain data integrity. You should also consider that the database for your project could probably be used by other applications in the future which might be based on other technologies than EF.
If you have relations in DB they will automatically be imported in your EF Model but you always have an option to create the associations manually in the EF Designer if you don't have relations in DB.
See How to manually add association in Entity Framework

JPA entity compatibility for both SQL Server and Oracle (auto-increment column issues)

I'm developing a Java EE JBoss service which will be deployed in two different environments: one using SQL Server as the database, and a different one which uses Oracle 10g.
My database schemas are very similar, except that the primary key columns are identity-auto-increment in SQL Server and generated using sequences in Oracle.
With JPA, is it possible to use a single set of entities with both DB's?
Thanks!
Of course you can, but just specify the generated-value definition for the PK field in XML metadata rather than annotations. Use 2 different "orm.xml" files, so, for example, use "persistenceUnitOracle" for Oracle that references orm-oracle.xml, and "persistenceUnitSqlServer" for SQLServer that references orm-sqlserver.xml

Entity Framework 4 column conversions - SQL Server - SQLite

I have a SQL Server database and Entity Framework Model setup with POCO objects, this is working fine. However, I have also created a Sqlite database from the SQL Server database (using a simple conversion process).
So I have created another EDMX file for the SQLite database, which I would like to use my existing POCOs generated from the SQL Server model and map them to the database. Unfortunately this maps the SQLite primary key integer columns as int64 (this seems to be the underlying integer type in SQLite), when they are simply ints in the SQL Server database.
This means when I try to map the new SQLite EDMX to my existing POCO objects (generated from the SQL Server EDMX by the POCO T4 Template), the objects cannot be mapped at runtime (and throw exceptions) because the id columns differ in type.
Does anyone know of a fix for this, for example is there a way to convert values in the entity framework edmx file? If there isn't I would consider this a fairly major limitation of the entity framework.
Thanks for any assistance.

Resources