Visual Studio Lightswitch 可以连接到 oracle 数据库吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3414345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can Visual Studio Lightswitch connect to an oracle database?
提问by Ian Ringrose
All the demos of Visual Studio Lightswitchuse SQL-Server, it is possible to access data from Oracle using Visual Studio Lightswitch?
Visual Studio Lightswitch 的所有演示都使用 SQL-Server,是否可以使用 Visual Studio Lightswitch 从 Oracle 访问数据?
采纳答案by one.beat.consumer
Visual Studio Lightswitch can be persisted to an Oracle Database via the Entity Framework.
Visual Studio Lightswitch 可以通过实体框架持久化到 Oracle 数据库。
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.
Notes: "11.2.0.2 Release 4" will cut it, but "11.2.0.3 is" out and more stable.
Third party drivers are available for purchase:
Open Source Providers
In addition there are some open source options available - one I found on Github:
Oracle 数据提供程序 (ODP.Net)
Oracle 的 ODAC 工具包含用于 Visual Studio 应用程序的 Oracle 数据提供程序 (ODP.Net)。Oracle 的最新驱动程序,支持实体框架 4.1 和“模型优先”方法。
编辑:我不确定它是否支持“代码优先”或 EF 4.2,因此请查看文档。也就是说,它是免费的并由 Oracle 提供支持,因此我强烈建议您先从这里开始,然后再推出自己的产品,或使用开源提供程序/驱动程序。
注意:“11.2.0.2 Release 4”会删减它,但“11.2.0.3 is”出来并且更稳定。
可以购买第三方驱动程序:
开源提供商
此外,还有一些可用的开源选项——我在 Github 上找到的一个:
Tutorial on MSDN: How to Connect Lightswitch to EF 4.1
回答by matt eisenberg
Yes, if you can get a third-part provider for the entity framework. I actually asked this question at VSLive this week.
是的,如果您可以获得实体框架的第三方提供程序。本周我实际上在 VSLive 上问了这个问题。
回答by kimsk
I have used the latest ODAC 11.2 Release 4 (11.2.0.3.0) that supports Entity Framework, and it works fine.
我使用了支持实体框架的最新 ODAC 11.2 第 4 版 (11.2.0.3.0),并且运行良好。
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
您可以按照 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.
基本上,您需要为 Oracle 数据源实现 SaveChanges_Excuting 和 SaveChanges_Excuted。
- Switch to "File View" (LightSwitch will display "Logical View" by default).
- Add a reference to "System.Transactions" in Server project.
- Switch back to "Logical View"
- Right Click the Data Source Name and click "View Code" to edit partial class.
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(); }
- 切换到“文件视图”(LightSwitch 将默认显示“逻辑视图”)。
- 在服务器项目中添加对“System.Transactions”的引用。
- 切换回“逻辑视图”
- 右键单击数据源名称,然后单击“查看代码”以编辑分部类。
复制并粘贴以下代码:
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(); }
回答by Damian Schenkelman
The LightSwitch training kithas an exercise dedicated to using alternative data sources via WCF RIA services.
该LightSwitch的培训教材,有一个专门用来通过WCF RIA服务使用替代数据源的练习。
You might find that useful.
你可能会发现这很有用。