简体   繁体   English

如何在asp.net MVC 3中将列添加到现有SQL Server 2008数据库表中

[英]How to add columns to an existing SQL Server 2008 database table in asp.net MVC 3

I'm looking to add 2 columns to an existing table in my SQL Server 2008 database. 我正在向SQL Server 2008数据库中的现有表添加2列。 I'm coming in on a poorly documented project, so I wondering, is it simply a case of adding to the class and entering add migration? 我要参加一个文档记录不充分的项目,所以我想知道,这仅仅是添加到类并输入添加迁移的一种情况吗?

The class is within an Entities folder in a Models project and the class uses the following attribute.. 该类位于Models项目的Entities文件夹中,并且该类使用以下属性。

 [PersistableEntitiesAttribute]

The properties are written as... 属性写为...

   public virtual string Username { get; set; }

Can I add two virtual properties to the class and use the PM to add migration? 我可以在类中添加两个虚拟属性并使用PM添加迁移吗?

Please note I am seeking to keep all data already in the Database and there is no migrations folder in this project. 请注意,我正在寻求将所有数据保留在数据库中,并且此项目中没有Migrations文件夹。

Asp.net MVC 3 application. Asp.net MVC 3应用程序。

Is there steps I follow to complete this task ? 我需要执行以下步骤来完成此任务吗?

Not sure if it's the correct way but I simply added the two virtual properties to my class.. 不知道这是否是正确的方法,但我只是将两个虚拟属性添加到类中。

  public virtual string ResetToken { get; set; }
  public virtual DateTime? ExpirationDateTime { get; set; }

and then added the same properties manually to the table in the database through the design view. 然后通过设计视图将相同的属性手动添加到数据库中的表中。

暂无
暂无

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

相关问题 如何将ASP.NET MVC5身份验证添加到具有用户角色表的现有数据库 - How to add ASP.NET MVC5 Identity Authentication to existing database that has User,Role Table 如何从 ASP.NET MVC 在 SQL 服务器的表中插入一些特殊列? - How to insert in some special columns in a table in SQL Server from ASP.NET MVC? 如何将外部SQL Server数据库添加到ASP.NET MVC应用程序(C#) - How to add external SQL Server database to an ASP.NET MVC application (c#) 如何将具有.MDF文件(SQL 2008)的现有ASP.NET MVC 3项目迁移到Windows Azure仿真器(使用SQL Azure) - How to migrate existing ASP.NET MVC 3 Project with .MDF file (Sql 2008) to Windows Azure Emulator (using SQL Azure) 在ASP.net MVC C#中显示SQL Server表的列 - Display the columns of a SQL Server table in ASP.net MVC C# Asp.Net Mvc从数据库表中删除列 - Asp.Net Mvc delete columns from database table 将数据库添加到现有SQL Server 2008 - Add database to existing SQL Server 2008 如何在C#ASP.Net中将表格数据从Excel上传到SQL Server 2008 - How to upload table data from Excel to SQL Server 2008 in C# ASP.Net 如何将LocalDb数据库移动到ASP.NET MVC托管服务器上的SQL Server数据库? - How to move LocalDb database to SQL Server database on the hosting server for ASP.NET MVC? 如何在默认的asp.net mvc项目中将值插入SQL Server中的现有行? - How do I insert values into existing rows in SQL server in default asp.net mvc project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM