ProviderManifestToken 2008 或 2012 [英] ProviderManifestToken 2008 or 2012

查看:13
本文介绍了ProviderManifestToken 2008 或 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序:

  • .NET 4.5 C#
  • 使用 EF6 和数据库优先方法
  • 支持 SQL Server 2008R2、2012 和 2014

这个问题是关于自动生成的 edmx 文件的 ProviderManifestToken 属性.

This question is regarding the ProviderManifestToken attribute of the auto-generated edmx file.

根据使用哪个版本的数据库(不同的开发人员有不同版本的数据库)从数据库更新模型,ProviderManifestToken 属性的值设置为 2008 或 2012. 在我们停止支持 SQL Server 2005 之前,我们确保此属性的值保持为 2005(请参阅 这篇 SO 文章了解更多信息).

Depending on which version of the database is used (different developers have different version of the database) to update the model from the database, the value of the ProviderManifestToken attribute either gets set to 2008 or 2012. Until we discontinued support for SQL Server 2005, we made sure that the value of this attribute remained 2005 (see this SO article for more information).

我想知道在 2008 年和 2012 年之间是否有类似的担忧.这个属性到底有什么作用?将其保留为任一值而不在运行时引起任何问题对我来说是安全的吗?或者我应该确保将其始终设置为 2008 或始终设置为 2012 以确保应用程序在我们支持的数据库版本中正常工作?

I am wondering if there are similar concerns between 2008 and 2012. What does this attribute really do? It is safe for me to leave it to either value without causing any issues at run time? Or should I make sure that this is always set to 2008 or always set to 2012 to make sure that the application works fine with the versions of the database that we support?

MSDN 在描述此属性时不是很有用.它指出 ProviderManifestToken

MSDN is not very useful in describing this property. It states that ProviderManifestToken is

一个字符串,用于标识正在使用的数据库服务器的版本用过的.例如,SQL Server 提供程序使用字符串2008"作为SQL Server 2008.这不能为空,但可以为空.

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.

谢谢!

推荐答案

从 EF 6.1.2 开始,将 2012 作为 ProviderManifestToken 值将导致 EF 使用 offset ... fetch ... 语法(MS Sql 2008 不支持)在很多情况下,比如分页.因此,如果您将其更改为 2012,您很可能会在运行 MS Sql 2008 的应用程序上遇到问题.

Since EF 6.1.2, having 2012as ProviderManifestToken value will cause EF to generate SQL using offset ... fetch ... syntax (not supported in MS Sql 2008) in a bunch of cases, like paging. So, if you let it get changed to 2012, you will very likely have troubles on apps running over MS Sql 2008.

将其设置为 2008 以便在较新的 Sql Server 上运行现在应该是安全的:不推荐使用的功能通常在 v+2 之前不会被删除(其中 v 是第一个不推荐使用的版本).抱歉,我找不到此声明的参考.

Setting it to 2008 for running on newer Sql Server should be safe for now: deprecated features are usually not dropped until v+2 (where v is the first version in which they have been deprecated). Sorry, I am no more able to find a reference for this statement.

如果您需要使其与每个部署的目标数据库相匹配,this other SO answer 可能会对您有所帮助.

If you need to have it match the target DB for each of your deployments, this other SO answer may help you.

如果您希望在任何情况下将其设置为 2008,确保开发数据库都设置为 100(SQL Server 2008) 兼容级别应该可以解决问题.不幸的是,看起来 EF 设计器并不总是尊重运行它以更新模型的数据库的兼容性级别.所以在使用它时,它可能会升级" ProviderManifestToken 的值,如果开发者提交它并让它被部署会造成麻烦.

If you wish to set it as 2008 in any cases, ensuring that development DBs are all set to 100(SQL Server 2008) compatibility level should do the trick. Unfortunately it looks like EF designer does not always honor the compatibility level of the database on which it runs for updating the model. So when using it, it may "upgrade" the ProviderManifestToken value, causing troubles if the dev commit it and let it get deployed.

我无法在自己的工作站上重现此内容.但是我公司的一些开发人员遇到了麻烦,尽管他们声称他们的本地数据库处于 100 兼容级别.

I was not able of reproducing this on my own workstation. But some devs in my company had the trouble, though they claim their local db is in 100 compatibility level.

他们似乎没有正确设置 SQL Server Management Studio (SSMS) 默认脚本选项.(Tools => Options... => SQL Server 对象浏览器 => Scripting => 服务器版本的脚本).以防万一,我让他们更改它,现在他们报告不再有不希望的 ProviderManifestToken 值升级.

It appears they were not having their SQL Server Management Studio (SSMS) default scripting option correctly set. (Tools => Options... => SQL Server Object Explorer => Scripting => Script for server version). Just in case, I made them change it, and for now they report no more having the undesired ProviderManifestToken value upgrade.

这对我来说看起来很奇怪,因为 SSMS 选项不应该对 EF 设计器产生任何影响.恕我直言,仅应考虑运行设计器的数据库.如前所述,我自己也无法重现此问题,即使调整该选项也是如此.

This looks quite weird to me, as SSMS options should not have any impact on EF designer. Only the database on which is run the designer should be taken into account IMHO. And as already stated, I was not able to reproduce this trouble myself, even by tweaking that option.

这篇关于ProviderManifestToken 2008 或 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆