entity-framework-migrations

Azure publish: Login failed for user 'xxxxxx'

旧巷老猫 提交于 2020-08-12 01:28:31
问题 I am using .NET backend for my Mobile App of Azure. I have been using Code-First migrations for my database and done many migrations and publishes so far. Everything was nice and smooth. Then I decided to reset my SQL Server password from Azure portal. After that things started to go south. The problems that I faced after password change: 1- When I tried Add-Migration blabla in Package Manager Console, Visual Studio told me that all my previous migrations must be applied first. 2- I tried

EF Migrations not able to remove migration

♀尐吖头ヾ 提交于 2020-08-05 06:02:12
问题 Edit: I dropped the database. It still tells me the migration is applied. I don't buy your shit, EF... I have 5 migrations, but the 5th has been created on accident. It doesn't hold any changes ( Up and Down methods are empty). Without thinking I appied it to the database. Now when I run dotnet ef database update migration4 it tells me it successfully reverted migration #5 and the table __EFMigrationsHistory doesn't show an entry for migration #5. Upon trying to remove it with dotnet ef

How DbMigrationsConfiguration is related to a DbMigration in EF

倾然丶 夕夏残阳落幕 提交于 2020-07-18 09:31:17
问题 In Entity Framework by using Enable-Migrations a Migrations folder is created containing a Configuration inherited from DbMigrationsConfiguration like this: internal sealed class Configuration : DbMigrationsConfiguration<MyDbContext> { ... } All the created migrations which are created using Add-Migration are placed in the Migrations folder too. public partial class Init: DbMigration { public override void Up() { ... } public override void Down() { ... } } I didn't find any code that relates

EntityFramework Core production migrations

人走茶凉 提交于 2020-07-10 05:40:34
问题 How do I update the database for production? I've moved the connection string secrets out of the application. Our CI/CD pipeline handles the token replacement within the connection string "template" that remains in the appsettings, and developers won't have production database access. I had expected to use automatic migrations, only to discover today that Microsoft eliminated that for EF Core. Will I have to, every time, temporarily overwrite the connection string that normally specifies my

EntityFramework Core production migrations

痴心易碎 提交于 2020-07-10 05:38:33
问题 How do I update the database for production? I've moved the connection string secrets out of the application. Our CI/CD pipeline handles the token replacement within the connection string "template" that remains in the appsettings, and developers won't have production database access. I had expected to use automatic migrations, only to discover today that Microsoft eliminated that for EF Core. Will I have to, every time, temporarily overwrite the connection string that normally specifies my

EF Core Migration: Could not load assembly 'AssemblyName'

落爺英雄遲暮 提交于 2020-07-07 05:38:05
问题 The command "Add-Migration InitialCreate" generates the following error message: Could not load assembly 'MathModelApp'. Ensure it is referenced by the startup project 'MathModelApp'. What does the error message mean? I am using netcore 2.1, Target Platform is x86. 回答1: Please go to solution property and check if you selected same project as the startup project in the solution or not. 回答2: Right Click on EndPoint Project Click on the Set As Startup Project 来源: https://stackoverflow.com

EF Core Migration: Could not load assembly 'AssemblyName'

血红的双手。 提交于 2020-07-07 05:35:12
问题 The command "Add-Migration InitialCreate" generates the following error message: Could not load assembly 'MathModelApp'. Ensure it is referenced by the startup project 'MathModelApp'. What does the error message mean? I am using netcore 2.1, Target Platform is x86. 回答1: Please go to solution property and check if you selected same project as the startup project in the solution or not. 回答2: Right Click on EndPoint Project Click on the Set As Startup Project 来源: https://stackoverflow.com

One-to-one and one-to-many relationships with same owned entity type

≡放荡痞女 提交于 2020-06-29 04:14:31
问题 After this question I tried working with owned entity types but I'm stuck at the following scenario: public class User { [Key] public Guid UserId { get; set; } public ICollection<Listing> Listings { get; set; } public Image Avatar { get; set; } } public class Listing { [Key] public Guid ListingId { get; set; } public ICollection<Image> Photos { get; set; } } [Owned] public class Image { public long Size { get; set; } public string Height { get; set; } public string Width { get; set; } }

Seed Roles (RoleManager vs RoleStore)

自古美人都是妖i 提交于 2020-06-28 06:46:08
问题 Through looking at the posts here, I've seen two different ways of creating ASP.NET Identity roles through Entity Framework seeding. One way uses RoleManager and the other uses RoleStore . I was wondering if there is a difference between the two. As using the latter will avoid one less initialization string[] roles = { "Admin", "Moderator", "User" }; // Create Role through RoleManager var roleStore = new RoleStore<IdentityRole>(context); var manager = new RoleManager<IdentityRole>(roleStore);

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