none
Entity Framework and multiple DBMS RRS feed

  • Question

  • I have an application that supports both SQL Server and DB2 on various platforms. I am converting this from VB6 to VS2012. Right now, the application creates queries and SQL commands manually. This process requires some tweaking because even though SQL is "standard" it isn't.

    I would like to take advantage of some of the Entity Framework features, but I am not sure how I can dynamically switch between two different database providers depending on which the user decides to use. I would like to avoid developing two separate versions of the program. I would rather stick to manual manipulation of the SQL commands. Does anyone have any experience with this or suggestions. I believe there is a provider from IBM, but I don't know how this works with dynamically adapting to the local database.


    Mike

    • Moved by Youen Zen Tuesday, March 26, 2013 3:09 AM From Visual Basic
    Monday, March 25, 2013 9:52 PM

All replies


  • There is a MSDN ADO.NET Entity Framework forum you can post to.

    Monday, March 25, 2013 11:51 PM
  • Hi  Mike,

    Welcome to the MSDN forum.

    I think you are using database fist or model first approach. You could use different connection strings as a parameter when you initial the dbcontext. Please refer to this page: http://msdn.microsoft.com/en-US/data/jj592674

    Good day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 26, 2013 8:46 AM
  • Thank you. I have not read through the page you suggest, but it looks like it will address the connection issue.

    I did a search of the old programs and found that I had to use different code in the following instances:

    1. When doing certain operations, I believe updates, I had to specify a CursorLocation of adUseClient for SQL Server and not for DB2.
    2. There are syntax differences in the CREATE TABLE ddl with regard to the Primary Key Constraint.
    3. There are syntax differences in the CREATE INDEX ddl.
    4. When doing insert operations, I do a query to the database that generates an empty ResultSet and can then add rows to that ResultSet to be posted back to the database. If I do that in DB2, when I try to add a row to the ResultSet, I get an error, so I have to use an SQL INSERT command instead.

    These are differences beyond the connection string. Are issues like these masked under the covers with the Framework? That would certain be a big plus in using the Framework. I can live with the DDL issues, since those are isolated to the setup program.


    Mike

    Tuesday, March 26, 2013 4:48 PM