简体   繁体   English

实体框架中ProviderManifests的向后兼容性

[英]Backwards compatibility of ProviderManifests in Entity Framework

Are the ProviderManifests used by EntityFramework backwards compatible, in particular for Oracle and SQL Server? EntityFramework使用的ProviderManifests是否向后兼容,尤其是对于Oracle和SQL Server?

I'm creating an instance of the DbProviderInfo class to pass to DbModel.Build(). 我正在创建DbProviderInfo类的实例以传递给DbModel.Build()。 The second argument to the constructor is the ProviderManifestToken. 构造函数的第二个参数是ProviderManifestToken。

As the documentation says, the ProviderManifestToken is: 文档所述,ProviderManifestToken为:

A string that identifies that version of the database server being used. 标识正在使用的数据库服务器版本的字符串。 For example, the SQL Server provider uses the string "2008" for SQL Server 2008. This cannot be null but may be empty. 例如,SQL Server提供程序对SQL Server 2008使用字符串“ 2008”。它不能为null,但可以为空。

There is a related, unanswered question here asking what ProviderManifestInfo does. 这里有一个相关的未解决问题询问ProviderManifestInfo的功能。 From reading this page I understand that it allows the database provider to determine which version of the ProviderManifest to return, without using a database connection. 通过阅读此页面,我了解到它使数据库提供程序无需使用数据库连接即可确定要返回哪个版本的ProviderManifest。 (What the ProviderManifest does is also explained at that last link.) (ProviderManifest的操作在最后一个链接中也有说明。)

Experimentally, I have found that I can use an Oracle 12 database with a ProviderManifestToken of "11.2" with no problems. 通过实验,我发现我可以使用ProviderManifestToken为“ 11.2”的Oracle 12数据库,而不会出现问题。 But is this supposed to be true in general? 但这通常是正确的吗? For example, if I pass "2008" as the ProviderManifestToken and I am using SQL Server 2012, can I expect 'things' to work OK? 例如,如果我将“ 2008”作为ProviderManifestToken传递,并且我正在使用SQL Server 2012,那么我可以期望“事物”正常工作吗?

I have been unable to find any documentation on this point and I would not be surprised if things are different from provider to provider. 关于这一点,我一直找不到任何文档,如果提供商之间的情况有所不同,我也不会感到惊讶。

But is this supposed to be true in general? 但这通常是正确的吗? For example, if I pass "2008" as the ProviderManifestToken and I am using SQL Server 2012, can I expect 'things' to work OK? 例如,如果我将“ 2008”作为ProviderManifestToken传递,并且我正在使用SQL Server 2012,那么我可以期望“事物”正常工作吗?

Yes, subject to the backwards-compatibility of the database provider. 是的,取决于数据库提供程序的向后兼容性。 Oracle and SQL Server, at least, are very reluctant to break existing applications in new versions of the database, so applications written for older versions typically work fine. 至少Oracle和SQL Server不太愿意在数据库的新版本中破坏现有的应用程序,因此为较旧版本编写的应用程序通常可以正常工作。

The main purpose pf the ProviderManifestToken is to allow EF to use new functionality for a database provider, without abandoning support for old versions. ProviderManifestToken的主要目的是允许EF在不放弃对旧版本的支持的情况下为数据库提供程序使用新功能。 For instance SQL Server introduced OFFSET .. FETCH paging in SQL 2012. And without the ProviderManifestToken EF would have to choose between using the older query form for paging (ROW_NUMBER() based), or drop support for SQL 2008. 例如,SQL Server在SQL 2012中引入了OFFSET .. FETCH分页。如果没有ProviderManifestToken,则EF必须选择使用旧的查询表单进行分页(基于ROW_NUMBER()),还是放弃对SQL 2008的支持。

It is possible that EF would generate a query that doesn't work correctly on a later version, which would be a bug in EF. EF可能会生成在更高版本上无法正常运行的查询,这可能是EF中的错误。 But I don't know of any such cases. 但是我不知道有任何这样的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM