English 中文(简体)
C# 4.0/EF - 服务器生成的钥匙和服务器生成的数值不为《契约》服务器提供支持
原标题:C# 4.0/EF - Server-generated keys and server-generated values are not supported by SQL Server Compact

我刚刚将我的一个项目移入了VS2010/fx4.0,并正在使用CEQ数据库作为背书库。 自此以后,这一版本已经进入。 NET,我现在正在发现这一错误:

服务器生成的钥匙和服务器生成的数值没有得到SQ服务器契约的支持。

我的表格was与用户Name (string) &的PK;DoorOpen (datetime) as ProfCE required在每张桌上就 f3.5。 现在,我坐在x4.0。 我为这一点 go,我发现的每一个答案都是:

航天中心不支持汽车生产价值(我当然不需要这种价值),因此,它在那里设置了国际建筑信息数据库,并从法典中填满。

我尝试了这种做法,我仍在犯同样的错误!

文 件:

CREATE TABLE [ImportDoorAccesses] (
    [RawData] nvarchar(100)  NOT NULL,
    [DoorOpen] datetime  NOT NULL,
    [UserName] nvarchar(100)  NOT NULL,
    [CardNumber] bigint  NOT NULL,
    [Door] nvarchar(4000)  NOT NULL,
    [Imported] datetime  NOT NULL,
    [ID] uniqueidentifier  NOT NULL -- new column
);

ALTER TABLE [ImportDoorAccesses]
ADD CONSTRAINT [PK_ImportDoorAccesses]
    PRIMARY KEY ([ID] );

制约因素如下:

ALTER TABLE [ImportDoorAccesses]
ADD CONSTRAINT [PK_ImportDoorAccesses]
    PRIMARY KEY ([DoorOpen],[UserName]);

CODE:

foreach (dto.DoorAudit newDoorAudit in dataTransferObject)
{
    if (newDoorAudit.DoInsert)
    {
        myEntities.AddToImportDoorAccesses(new ImportDoorAccess
        {
            CardNumber = newDoorAudit.CardNumber,
            Door = newDoorAudit.Door,
            DoorOpen = newDoorAudit.DoorOpen,
            Imported = newDoorAudit.Imported,
            RawData = newDoorAudit.RawData,
            UserName = newDoorAudit.UserName,
            ID = Guid.NewGuid()  // LOOK - HERE IT IS AS SUGGESTED!
        });
    }
}
myEntities.SaveChanges();

因此,现在是什么? 这在EF4中是否是一种ug? 我做了一些错误?

TIA


注:

通过EDMX文档(右翼和XML开放) 我发现,我的日期一栏为StoreGeneratedPattern=“Identity”

  <EntityType Name="ImportDoorAccesses">
    <Key>
      <PropertyRef Name="ID" />
    </Key>
    <Property Name="RawData" Type="nvarchar" Nullable="false" MaxLength="100" />
    <Property Name="DoorOpen" Type="datetime" Nullable="false" />
    <Property Name="UserName" Type="nvarchar" Nullable="false" MaxLength="100" />
    <Property Name="CardNumber" Type="bigint" Nullable="false" />
    <Property Name="Door" Type="nvarchar" Nullable="false" />
    <Property Name="Imported" Type="datetime" StoreGeneratedPattern="Identity" Nullable="false" />
    <Property Name="ID" Type="uniqueidentifier" Nullable="false" />
  </EntityType>

然后,我转回了原样式的观点,并在我数据库的每一个一栏点上点击,以确保这套数据为NOT。 A PITA forbeit. 象一个完美的工具/工具一样,需要创建......

最佳回答

检查的重要内容是EDMX档案,并确保该财产/col在其中拥有一个具有身份的仓库。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签