entity-framework-migrations

Unknown CS1003 Error

醉酒当歌 提交于 2020-06-27 18:38:27
问题 I can't compile my project for code-first migrations in entity framework past a certain point. I am reading in values from xml to populate a table. I have the following code: //EnrolmentProgramStartDate var programQuery = from r in context.EnrolmentPrograms select r; var programList = programQuery.ToList<Entities.MetaData.Enrolment.EnrolmentProgram>(); resourceName = "LearnLogicElicos_WebApi.SeedData.MetaData.Enrolment.enrolment_program_start_date.xml"; stream = assembly

How use DbContext in migration?

别说谁变了你拦得住时间么 提交于 2020-06-27 18:30:27
问题 How can I use DbContext which works with the current database (that now use in migration). Example: namespace Data.SqlServer.Migrations { [DbContext(typeof(MyDbContext))] // I want use this context [Migration("CustomMigration_DataSeed")] public partial class DataSeedMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { // add some entities _context.User.Add(new User()); } protected override void Down(MigrationBuilder migrationBuilder) { } } } Thanks for help!

Entity Framework Migration Azure DevOps Release Pipeline

女生的网名这么多〃 提交于 2020-06-27 08:11:23
问题 I'm trying to run migration on Azure DevOps Release Pipeline. Because I want to run my DB scripts automatically on every release. My release pipeline does not have source code, I just have compiled DLLs. When I execute this command on my local machine, it runs successfully. How can I convert this command so I can use it with DLLs. dotnet ef database update --project MyEntityFrameworkProject --context MyDbContext --startup-project MyStartupProject 回答1: If you don't want to include your source

EF migration shows empty Up() Down() methods, no tables created in database

泄露秘密 提交于 2020-06-27 06:03:53
问题 EF migration shows empty Up() Down() methods _migrationhistory created in database but no tables has been created code for creating model Public partial class Student:BaseEntity { public string name { get; set; } public string collegeName { get; set; } public int numberOfBooks { get; set; } } code for model mapping public partial class StudentMap: EntityTypeConfiguration<Student> { public StudentMap() { this.ToTable("Students"); this.HasKey(c => c.Id); this.Property(c => c.name); this

Add foreign key to AspNetUser table

跟風遠走 提交于 2020-01-11 14:48:12
问题 I've created an ASP.NET Core Razor Pages application with user identities. The created project includes a migration that adds all the user tables, such as AspNetUser and AspNetRoles . However, it doesn't create any code models for these tables. Now I've created my own entity models and I would like some of them to have foreign keys to the AspNetUser table. How can I do this? Does the platform expose these as classes anyplace? Do I need to manually create models and try to get them to exactly