The entity type ‘IdentityUserLogin’ requires a primary key to be defined [duplicate]

keys of Identity tables are mapped in OnModelCreating method of IdentityDbContext and if this method is not called, you will end up getting the error that you got. All you need to do is call. protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); } The original answer (just copied for other’s reference just in case) here

Stored Procedures and updating EDMX

(This solution is for EF 6. I have not tried in other EF versions. It works nice.) Go to Model browser. MyStoreProc is the name of the stored procedure (as an example). MyStoreProc will appear in 3 places. 1st place- Under Complex Types-> as MyStoreProc_result 2nd Place- Under Function Imports -> as MyStoreProc 3rd Place …

Read more

Default value for Required fields in Entity Framework migrations?

In addition to the answer from @webdeveloper and @Pushpendra, you need to manually add updates to your migration to update existing rows. For example: public override void Up() { Sql(“UPDATE [dbo].[Movies] SET Title=”No Title” WHERE Title IS NULL”); AlterColumn(“dbo.Movies”, “Title”, c => c.String(nullable: false,defaultValue:”MyTitle”)); } This is because AlterColumn produces DDL to set the default …

Read more

How to change the output folder for migrations with Core?

dotnet ef migrations add Initial –context EsportshubApi.Models.ApplicationDbContext -o YourFolderPath dotnet ef migrations add Adds a new migration. Arguments: Argument Description <NAME> The name of the migration. Options: Option Short Description –output-dir <PATH> -o The directory used to output the files. Paths are relative to the target project directory. Defaults to “Migrations”. –namespace <NAMESPACE> -n The …

Read more