That solution does not work in .net core 2 tied to SQL Server 2016. Original Question: Trying to jump into entity framework, using the "Code First Approach". I have my new class setup “NewTable” shown below. I can’t figure out what in the Program Manger Console I need to type to get this table created in my Default Connection String (pointing to a local instance of Sql Server 2016). The database is working and the user in this .net core 2 web app can register his/her name then log in using that new created account. Thanks in advance!!
Default Connection String:
"ConnectionStrings": { "DefaultConnection" "Server=localhost\RCDSE_Dev;Database=Some Database;User ID=sa;Password=SomePass;" },
[Table("NewTable")] public class NewTable { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] //Database generated key [Key] //Primary Key public long Id { get; set; } [Required] public string Manager { get; set; } } public class NewTableContext : DbContext { public DbSet<NewTable> NewTables{ get; set; } }
Add-Migration ..,Update-Database. More information hereAdd-Migration [name of migration]Then yesUpdate-Database