{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5893","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5893/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5893/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5893/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5893","id":162826717,"number":5893,"title":"[Question] How to specify foreign key column names using fluent API?","user":{"login":"alaatm","id":2095803,"avatar_url":"https://avatars.githubusercontent.com/u/2095803?v=3","gravatar_id":"","url":"https://api.github.com/users/alaatm","html_url":"https://github.com/alaatm","followers_url":"https://api.github.com/users/alaatm/followers","following_url":"https://api.github.com/users/alaatm/following{/other_user}","gists_url":"https://api.github.com/users/alaatm/gists{/gist_id}","starred_url":"https://api.github.com/users/alaatm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alaatm/subscriptions","organizations_url":"https://api.github.com/users/alaatm/orgs","repos_url":"https://api.github.com/users/alaatm/repos","events_url":"https://api.github.com/users/alaatm/events{/privacy}","received_events_url":"https://api.github.com/users/alaatm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-06-29T02:14:24Z","updated_at":"2016-06-29T09:19:36Z","closed_at":"2016-06-29T04:58:06Z","body":"In EF 6.x, we could specify foreign key column names in relations using fluent API as follows:\r\n`HasRequired(p => p.x).WithMany().Map(m => m.MapKey(\"fk\"));`\r\n`HasMany(p => p.x).WithRequired().Map(m => m.MapKey(\"fk\"));`\r\netc...\r\n\r\nI am not sure how can this be done in EF Core 1.0. I prefer not to use ForeignKey attribute."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/229303202","html_url":"https://github.com/aspnet/EntityFramework/issues/5893#issuecomment-229303202","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5893","id":229303202,"user":{"login":"alaatm","id":2095803,"avatar_url":"https://avatars.githubusercontent.com/u/2095803?v=3","gravatar_id":"","url":"https://api.github.com/users/alaatm","html_url":"https://github.com/alaatm","followers_url":"https://api.github.com/users/alaatm/followers","following_url":"https://api.github.com/users/alaatm/following{/other_user}","gists_url":"https://api.github.com/users/alaatm/gists{/gist_id}","starred_url":"https://api.github.com/users/alaatm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alaatm/subscriptions","organizations_url":"https://api.github.com/users/alaatm/orgs","repos_url":"https://api.github.com/users/alaatm/repos","events_url":"https://api.github.com/users/alaatm/events{/privacy}","received_events_url":"https://api.github.com/users/alaatm/received_events","type":"User","site_admin":false},"created_at":"2016-06-29T09:19:35Z","updated_at":"2016-06-29T09:19:35Z","body":"@rowanmiller Maybe the question was not clear. I know how to create relations and foreign keys but my question was about giving a custom name for the foreign key column.\r\n\r\nFor example, the sample code below:\r\n\r\n    modelBuilder.Entity<Post>()\r\n                .HasOne(p => p.Blog)\r\n                .WithMany(b => b.Posts)\r\n                .HasForeignKey(p => p.BlogForeignKey);\r\n\r\nwill generate a column named `BlogForeignKey`. My question was how to give it a different name. In EF 6.x we had the `Map` method: `.Map(m => m.MapKey(\"foreign_key_column_name\"));`\r\n\r\n"}}
{"actor":{"display_login":"alaatm"}}