Code First Migrations With Existing Table

跟風遠走 提交于 2019-11-29 12:56:35

问题


In my model I have navigation property Language:

public class IntegratorDescription : BaseContract
{
    [Key, Column(TypeName = "bigint"), DataMember]
    public long Id { get; set; }
    [DataMember, Column(TypeName = "bigint"), ForeignKey("Language")]
    public long LangId { get; set; }
    [DataMember]
    public string CompanyShortInfo { get; set; }
    [DataMember, Column(TypeName = "ntext")]
    public string CompanyInfo { get; set; }

    public virtual Models.Language Language { get; set; }
}

Language table already exists and it's done by another ORM, I need to say Migrations not to try to create Language table but update only Description table. How?

-"There is already an object named 'Languages' in the database."


回答1:


-IGNORECHANGES

Scaffolds an empty migration ignoring any pending changes detected in the current model. This can be used to create an initial, empty migration to enable Migrations for an existing database. N.B. Doing this assumes that the target database schema is compatible with the current model.

http://coding.abel.nu/2012/03/ef-migrations-command-reference/



来源:https://stackoverflow.com/questions/12088346/code-first-migrations-with-existing-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!