Question

All the demos of Visual Studio Lightswitch use SQL-Server, it is possible to access data from Oracle using Visual Studio Lightswitch?

Was it helpful?

Solution

Visual Studio Lightswitch can be persisted to an Oracle Database via the Entity Framework.

  1. Oracle Data Provider (ODP.Net)

    Oracle's ODAC Tools contains the Oracle Data Provider (ODP.Net) for use with Visual Studio applications. Oracle's latest driver with support for Entity Framework 4.1 and "Model First" approach.

    EDIT: I am not sure if it supports "Code-First" or EF 4.2 so check documentation. That said, it's free and supported by Oracle so I would strongly suggest starting here before rolling your own, or using open source providers/drivers.

    Download ODP.Net 11.2.0.3

    EF Tutorial w/ ODP.Net

    Notes: "11.2.0.2 Release 4" will cut it, but "11.2.0.3 is" out and more stable.

  2. Third party drivers are available for purchase:

    docConnect for Oracle

    DevArt's ADO.Net Provider for Oracle

  3. Open Source Providers

    In addition there are some open source options available - one I found on Github:

    https://github.com/object/NorthwindOData


Tutorial on MSDN: How to Connect Lightswitch to EF 4.1

OTHER TIPS

Yes, if you can get a third-part provider for the entity framework. I actually asked this question at VSLive this week.

I have used the latest ODAC 11.2 Release 4 (11.2.0.3.0) that supports Entity Framework, and it works fine.

If you get this error, "Inner exception message: Connection is already part of a local or a distributed transaction"

you can resolve the issue by following the second post by BScholz, https://forums.oracle.com/forums/thread.jspa?threadID=2263095

Basically, you need to implement SaveChanges_Excuting and SaveChanges_Excuted for the Oracle Data Source.

  1. Switch to "File View" (LightSwitch will display "Logical View" by default).
  2. Add a reference to "System.Transactions" in Server project.
  3. Switch back to "Logical View"
  4. Right Click the Data Source Name and click "View Code" to edit partial class.
  5. Copy-and-paste the code below:

    private TransactionScope _tscope;
    
    partial void SaveChanges_Executing()
    {
        _tscope = new TransactionScope(TransactionScopeOption.Required,
        new TransactionOptions
        {
            IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
        });
    }
    
    partial void SaveChanges_Executed()
    {
        _tscope.Complete();
        _tscope.Dispose();
    }
    

The LightSwitch training kit has an exercise dedicated to using alternative data sources via WCF RIA services.

You might find that useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top