简体   繁体   English

如何在表格中添加列?

[英]How to add a column in table?

I have Silverlight 5 application. 我有Silverlight 5应用程序。 It uses Entity framework "Model first". 它使用实体框架“模型优先”。 I added new column in entity in .edmx file, but i have 11009 error "property is not mapped". 我在.edmx文件中的实体中添加了新列,但出现11009错误“属性未映射”。 Google said that for mapping the property must be already in the table, so how i can add it? 谷歌表示,用于映射的属性必须已经在表中,所以我如何添加它? I have never worked with Silverlight and C# before, and need some help.. 我以前从未使用过Silverlight和C#,因此需要一些帮助。

UDT: Apparently i wrote question not correctly. UDT:显然我写的问题不正确。 I know, that i have to add column in database table, but how? 我知道,我必须在数据库表中添加列,但是如何? I dont have access for this in "Model browser" 我无法在“模型浏览器”中访问此文件

我可以用桌子做

  1. Delete 删除
  2. Refresh model from DataBase 从数据库刷新模型
  3. Create database with the use of model (database is already existing *me) 使用模型创建数据库(数据库已经存在* me)
  4. Add new code element 添加新的代码元素
  5. Check 校验
  6. Properties 属性

UDT UDT

I put the following code in XML.edmx file like Crud said 我像Crud所说的那样将以下代码放在XML.edmx文件中

<Property Name="BPP" Type="varchar" MaxLength="19" /> in SSDL content <ScalarProperty Name="BPP" ColumnName="BPP" /> in CS mapping content <ScalarProperty Name="BPP" ColumnName="BPP" />内容中的<Property Name="BPP" Type="varchar" MaxLength="19" /> <ScalarProperty Name="BPP" ColumnName="BPP" /> CS映射内容中的<ScalarProperty Name="BPP" ColumnName="BPP" />

But now i have Error 2009: Property on conceptual side, which is part of MSL, doesn't exists in MetadataWorkSpace 但是现在我有错误2009:概念方面的属性,它是MSL的一部分,在MetadataWorkSpace中不存在

You should add the new column in your database tables. 您应该在数据库表中添加新列。 After doing that update your edmx file. 完成之后,更新您的edmx文件。

If you already have the database so better to use DbFirst approch.it is easy to modify your model.in your case you can just update the database first ant simply you can update the model as well. 如果您已经拥有数据库,那么可以使用DbFirst approch更好。修改模型很容易。在这种情况下,您可以先更新数据库,也可以更新模型。

Any way if you want to alter the table with new column you should have to manually update the 2 of layers of edmx file.. Just open the edmx file as an xml and just add the inserted column details corresponding entity. 无论如何,如果您想用新列更改表,则必须手动更新edmx文件的2层。只需打开edmx文件作为xml,然后添加插入的列详细信息对应的实体。 You have to modify manually with the following layers. 您必须使用以下层进行手动修改。

  • SSDL content SSDL内容
  • CS mapping content CS映射内容

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

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