We started using EF 5.0 with MVC 4 and everything was working great. Our application is a product where the DB can be dynamic (SQL, Oracle, AS400 etc). So we created entities and map it to DB based on Connection String. If ConnectionString says Oracle we set the dbcontext connection to Oracle.
Now the problem is there is a table in SQL and Oracle with same datatype number(18,0) and if Entity datatype is set to Double, it works with Oracle but not with SQL.
Because Oracle to Entity datatype mapping for number(18,0) is double but SQL number(18,0) is decimal in EF5.0
IS there a way that I use same entity mapping targetting dynamic DB's (SQL or Oracle or AS400)
I have same problem, until now I only found this:
http://mosesofegypt.net/post/Multiple-database-support-with-Entity-Framework.aspx
I´m using "database first". Maybe "Code first" will solve it, but it took 40 seconds at the first database connection after program has started, I think all the SSDL definition is retrieved dynamically from database in that 40 seconds (every time program is started!). This was unaccetable for me so I decided to use "database first" where all the schemainformation is prestored in the edmx file (SSDL-part). But this is not database independet, as I just have learned.
Related
It is my first time to post here. My question is what code can we use instead of ExecuteReader? We're currently doing a total production program and we want to input the productions, Projects 1-4 (I label it P1-P4) into the text box, but i have read that ExecuteReader is only for SQL, we're only using Access DB. Our code for displaying the projects to textboxes
You apparently don't know what "SQL" is. SQL (structured query language) is not a database. It is a language that databases use to define and manipulate data. Just about all databases use SQL for this purpose, including Access.
There are a number of databases with "SQL" in the name, e.g. SQL Server, MySQL and SQLite, but there's no database named "SQL". Some people lazily refer to Microsoft's SQL Server as just SQL or maybe MS SQL but its name is SQL Server.
As for using ExecuteReader, it's for any database. If you were connecting to SQL Server then you'd use a System.Data.SqlClient.SqlCommand object and call ExecuteReader on that. As you're using Access, you need to use a System.Data.OleDb.OleDbCommand and call ExecuteReader on that. They both work the same way but the different providers are for different data sources.
I try to convert mysql data base to mssql, I used SSMA.
At first I converted schema from mysql to mssql, then I synchronized it.
Finally I migrated data's and faced with these errors:
Column 'column1 for example' does not allow DBnull.vallue
used softwares:
sql server 2016
mysql work bench 6.1
SSMA
In this case, I’d like to suggest you either change the source data to ‘0000-00-01’ works well with ‘Zero-date in NOT NULL Columns’ or set destination column to NULL so you could process null data after the migration is complete.
Ok so I have a little problem...
In my project we have a Oracle SQL Server. In the database I have access to some of an other users tables:
Tables:
|-bla
|-bla
Users:
|-otherUser (let's just call him that)
|-Tables:
|-aTable
In Oracle, to access the aTable table I use SELECT * FROM otherUser.aTable
Now, we also have a MS SQL CE database to which I sync the data from the OracleDB using the MS Sync f/w. And in the CE db - after sync - I get a table otherUser.aTable. This sounds good, so even though the CE doesn't have the User concept it just adds the same table.
BUT the problem is that when calling the same SQL query on CE as on Oracle I get a The table name is not valid error. Instead if I want to get the content of the table, the two ways that I have found to work is surrounding the otherUser.aTable with either [] or "".
However neither of them seem to work with Oracle. The [] seem to be an illegal name, and the "" seem to search for a table called just that (not an other user).
So why don't I just use the one way on Oracle and the other on CE? well I also use NHibernate as a ORM and it kind of needs the same table name for both the databases...
Is there a third way to encapsulate the table name that works with users in Oracle and just works in CE? or do you have any other ways to fix this issue?
I have no experience with MS SQL, but it seems like a problem that might be solved with synonyms on Oracle side.
Try to create synonym "otherUser.aTable" for otherUser.aTable in Oracle.
We have to work with legacy database and many tables have a column called upsize_ts of datatype timestamp not related to the data stored.
What is its purpose? Is this some sort of rowversion column? Can we delete that column?
I have found, that "upsize_ts" column is created when upgrading MS Access database to MSSQL using Upsizing wizard:
Upsizing is the process of migrating some or all database objects from
a Microsoft Access database (.mdb) to a new or existing Microsoft SQL
Server database or new Microsoft Access project (.adp).
The upsize wizard documentation mentions following:
Timestamp Columns
By default, the Upsizing Wizard creates new columns with the data type of timestamp in SQL Server tables generated from Microsoft Access
tables that contain floating-point (single or double), Memo, or OLE
fields.
Can we delete that column?
This field should not be deleted if database will still be used by MS Access (which is case for our app).
More About Upsizing Wizard:
http://office.microsoft.com/en-us/access-help/use-the-upsizing-wizard-HP005273009.aspx
Is this some sort of rowversion column?
Yes, it is. In versions of SQL Server before 2008, TIMESTAMP is the equivalent to ROWVERSION.
Can we delete that column?
No one can answer that for you - you need to find out if it really is not used anywhere.
This is the second time it happens to me and before modifying a 3rd party Database structure I wanted to know if anyone knew a better solution:
I'm accessing a MS SQL Server 2008 from a Lotus Notes Agent (Notes 7) to retrieve some data. I use LSXODBC and my "Select" statement works perfect... Except that my agent cannot "understand" Nvarchar SQL Field types. Any other data types work ok (can get the values from number and dates fields without a problem).
It took me a while to figure it out, and I couldn't find a solution (other than modifying the field types on the SQL table to Varchar instead of nVarchar)
I could replicate this both in MS SQL 2005 and 2008.
Last "elegant" solution was to create an SQL view -instead of modifying table structure- with the varchar types instead of nvarchar. Works ok but I have to create a view for each table I'm retrieving data from.
I tried to set the Field type using FieldExpectedDataType Method but didn't work. Still got a DB_TYPE_UNDEFINED.
I thought there might be some configuration issues? or maybe I'm using an old LN Version / ODBC Driver version?
Any hint would be greatly appreciated.
Thank you in advance.
Diego
An old ODBC driver may not support unicode. It was not added until SQL Server 2000 (I'm fairly sure)