4000型号,一是实体框架最大字符串长度 [英] Model-First Entity Framework Max String Length of 4000

查看:315
本文介绍了4000型号,一是实体框架最大字符串长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个项目,我有一个SQL Server CE 3.5数据库。

For a project I have a SQL Server CE 3.5 database.

据访问/通过与模型的第一种方法的实体框架创建。

It is accessed / created through entity framework with the model-first approach.

现在我有一些字符串在我的EDMX,其中有规定的最大长度类型的列。

Now I have some String typed columns in my EDMX, which have the max length specified.

EDMX declaration
<Property Name="Description" Type="nvarchar" Nullable="false" MaxLength="Max" />

生成的代码( *。SQLCE 文件)表示,从该模型中的最大长度的字符串列 nvarchar的(4000)中产生列。

The generated code (*.sqlce file) shows that from the max-length string column in the model a nvarchar(4000) column is generated.

.edmx.sqlce file (sql to create the database)
[Description] nvarchar(4000)  NULL,

这是不是该应存放在这些列中的字符串足够长的时间。

This is not long enough for the strings that shall be stored in these columns.

在某些代码优先方法解决这个问题,我已经看到 NTEXT 数据类型可以提供帮助,因为它不具备4000个字符限制。

In some code-first approach solutions to this issue I have seen that the ntext datatype can help, because it does not have the 4000 chars limit.

如何解决这个模型中,第一个环境中才能实现?

How can this be achieved in a model-first environment?

推荐答案

添加定长=false的 - 这样:

Add FixedLength="false" - so:

<Property Name="Text" Type="String" Nullable="false" MaxLength="Max" FixedLength="false" />



然后,它为NTEXT使用标准模板

Then it is generated as ntext using the standard template

当然,你必须当向导出现这个工作连接到SQL Server Compact数据库文件。你可以安装我的SQL Server Compact工具箱在VS 2012年或更新

Of course you must connect to a SQL Server Compact database file when the wizard comes up for this to work. You can install my SQL Server Compact Toolbox to enable this in VS 2012 or newer

这篇关于4000型号,一是实体框架最大字符串长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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