0

I am developing a web application using ASP.NET MVC with Entity Framework. After I finished, the IT told me that they cannot use SQL Server localdb on their server, so I need to transfer to an Oracle database. The problem is, I have no idea how to accomplish this.

What I managed to far: I found out I need to use Oracle Entity Framework and somehow managed to add Oracle.ManagedDataAccess.EntityFramework (the internet is pretty restricted here and I could not use NuGet). I also modified the connection string and provider. The problem is, an exception occurs:

An exception of type 'System.Data.Entity.Core.ProviderIncompatibleException' occurred in EntityFramework.dll but was not handled in user code

Additional information: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file.

Web.config:

<add name="DBCS" 
     connectionString="DATA SOURCE=source;PASSWORD=pass;PERSIST SECURITY INFO=True;USER ID=user" 
     providerName="Oracle.ManagedDataAccess.Client" />
 ...
<entityFramework>
    <defaultConnectionFactory 
            type="Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, Oracle.ManagedDataAccess.EntityFramework">
        <parameters>
            <parameter value="mssqllocaldb" />
        </parameters>
    </defaultConnectionFactory>
    <providers>
        <provider invariantName="Oracle.ManagedDataAccess.Client" 
                  type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </providers>
</entityFramework>

Context and how I use it:

 public class InventoryContext : DbContext
 {
    public InventoryContext() : base("DBCS")
    { }
 ...
 }

 InventoryContext db = new InventoryContext();
 db.Items.ToList() //use the rows

How can I make it work?

8
  • you have to use nugget to remove and add necessary components. other wise very difficult to configure it. Commented Sep 22, 2016 at 10:25
  • unfortunately any attempt to use nuget results in this error Install-Package : Unable to load the service index for source api.nuget.org/v3/index.json. Commented Sep 22, 2016 at 10:36
  • that is may be restrictions of your internet.how can we help you ? Commented Sep 22, 2016 at 10:39
  • @Sampath thank you for your support. Is the usage of the context correct also for Oracle? Or should I modify the provider / anything else in the web.config file? The exception suggests that I should change the provider, but this is the one I found here link Commented Sep 22, 2016 at 10:45
  • the thing here is all devs are doing it using nugget.we can support it if you'll have any issues after the nugget update.these days no one is doing it manually. I have sorted out an issue which it came after the nugget update.you can see that here :stackoverflow.com/questions/39605532/… Commented Sep 22, 2016 at 10:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.