ProviderManifestToken 2008或2012 [英] ProviderManifestToken 2008 or 2012

查看:305
本文介绍了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(请参阅

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 is not very useful in describing this property. It states that ProviderManifestToken is

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

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 ...语法生成SQL(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.

如果您需要使其与每个部署的目标数据库都匹配,则其他SO答案可能会为您提供帮助

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 Object Explorer => Scripting => Script for server version).为了以防万一,我让他们进行了更改,现在他们报告不再有不需要的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天全站免登陆