我使用迁移时表格不更新(更新数据库) [英] My Tables Not Update When I Use Migration (Update-Database)
本文介绍了我使用迁移时表格不更新(更新数据库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
i将我的个人资料类更改为;
[表格( UserProfile)]
public 类 UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get ; set ; }
[显示(名称= نامکاربری)]
public string UserName { get ; set ; }
[显示(名称= نام)]
public string 名称{ get ; set ; }
[显示(名称= نامخانوادگی)]
public string Family { get ; set ; }
}
然后我使用迁移进行更新表:
PM> update-database -verbose -force
使用StartUp项目'Nezam'。
使用NuGet项目'Nezam'。
指定'-Verbose'标志以查看应用于目标数据库的SQL语句。
目标数据库是:'NezamDB'(DataSource:(LocalDb)\ v11.0,Provider:System.Data.SqlClient,Origin:Configuration)。
应用基于代码的迁移:[201404080747414_Initial]。
应用基于代码的迁移:201404080747414_Initial。
[插入迁移历史记录]
运行种子方法。
PM>
但个人资料表未更新:
http://oi62.tinypic.com/rbhzl2.jpg
解决方案
嘿伙计,
您可以参考以下文章:
Code First Migration简介
< a href =http://www.c-sharpcorner.com/UploadFile/4b0136/perform-code-first-migration-in-Asp-Net-mvc-5/>在MVC中执行代码优先迁移
hi
i change my profile class to ;
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
[Display(Name = "نام کاربری")]
public string UserName { get; set; }
[Display(Name = "نام")]
public string Name { get; set; }
[Display(Name = "نام خانوادگی")]
public string Family { get; set; }
}
then i used migration for update tables:
PM> update-database -verbose -force
Using StartUp project 'Nezam'.
Using NuGet project 'Nezam'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'NezamDB' (DataSource: (LocalDb)\v11.0, Provider: System.Data.SqlClient, Origin: Configuration).
Applying code-based migrations: [201404080747414_Initial].
Applying code-based migration: 201404080747414_Initial.
[Inserting migration history record]
Running Seed method.
PM>
but profile Table not update :
http://oi62.tinypic.com/rbhzl2.jpg
解决方案
Hey buddy,
You can refer to the following articles:
Introducing Code First Migration
Performing Code First Migration in MVC
这篇关于我使用迁移时表格不更新(更新数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文