【发布时间】:2017-05-11 14:29:21
【问题描述】:
在现有项目中,我如何知道它是代码优先还是数据库优先?
项目有这行代码:
public class TestDBContext : DbContext
{
public DbSet<Player> Players { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
并且项目没有.edmx 文件。如果需要任何其他细节,我会分享。
编辑:
Player.cs 类
public class Player
{
public int PlayerID { get; set; }
public string PlayerName { get; set; }
}
编辑 12.05.2017
如果我将 database name 从 connection string 更改并运行项目,它会创建 database with the new name with all tables。可能这会被打到答案。
【问题讨论】:
-
任何迁移类?
-
@ErikEJ 你是说 player.cs 类吗?
-
不,我的意思是具有迁移代码的类(我认为是从 DbMigration 继承)
标签: c# entity-framework ef-code-first db-first