Click here to Skip to main content
15,793,452 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: asp.net Pin
Richard Deeming18-Jan-22 2:44
mveRichard Deeming18-Jan-22 2:44 
QuestionError NETSDK1045 The current .NET SDK does not support targeting .NET Core 2.2 Pin
Member 1547980726-Dec-21 4:52
Member 1547980726-Dec-21 4:52 
AnswerRe: Error NETSDK1045 The current .NET SDK does not support targeting .NET Core 2.2 Pin
OriginalGriff26-Dec-21 4:53
mvaOriginalGriff26-Dec-21 4:53 
AnswerRe: Error NETSDK1045 The current .NET SDK does not support targeting .NET Core 2.2 Pin
Mycroft Holmes26-Dec-21 12:45
professionalMycroft Holmes26-Dec-21 12:45 
GeneralRe: Error NETSDK1045 The current .NET SDK does not support targeting .NET Core 2.2 Pin
Member 1547980726-Dec-21 19:21
Member 1547980726-Dec-21 19:21 
QuestionHttps redirection modifies url path Pin
Member 1547511221-Dec-21 2:10
Member 1547511221-Dec-21 2:10 
AnswerRe: Https redirection modifies url path Pin
Richard Deeming4-Jan-22 1:26
mveRichard Deeming4-Jan-22 1:26 
QuestionHow to fill Foreign Key in a relational database when creating a new row? Pin
Alex Dunlop19-Dec-21 8:12
Alex Dunlop19-Dec-21 8:12 
I have a model as follows:

[Key]
public int pmId { get; set; }
[Required]
public int pmNumber { get; set; }
[Required]
[MaxLength(50)]
public string costCenter { get; set; }
[Required]
[MaxLength(15)]
public string serviceType { get; set; }
[Required]
[MaxLength(50)]
public string destination { get; set; }
[Required]
[MaxLength(50)]
public string workCenter { get; set; }
[Required]
public DateTime creationDate { get; set; }
[Display]
[Required]
public DateTime startDate { get; set; }
[Required]
public DateTime endDate { get; set; }
[Required]
[MaxLength(100)]
public string mainFileName { get; set; }
public DateTime? returnDate { get; set; }
public string? status { get; set; }
[MaxLength(100)]
public string? fileName { get; set; }
public int? uploader { get; set; }
public bool? isDownloaded { get; set; } = false;

//Navigation property
public virtual AppUser user { get; set; }
//Navigation property
public PM()
{

}


The Foreign Key is id which is Primary Key of the EF Core Identity table. In a form, I need to insert a new row in PM table. I can fill all necessary columns using the following code:

var inputElements = new PM()
            {
                pmNumber = Convert.ToInt32(adminModel.pmNumber),
                costCenter = adminModel.costCenter,
                serviceType = adminModel.serviceType,
                destination = adminModel.destination,
                workCenter = adminModel.workCenter,
                creationDate = DateTime.Now,
                startDate = DateTime.Now,
                endDate = DateTime.Now,
                mainFileName = newFileName
            };


But, because of relational nature of my tables, I need to specify userId when creating a new row in PM table. How can I set Foreign Key? I can detect userId using Session object but I don't know how to insert it in the table.

modified 19-Dec-21 13:22pm.

AnswerRe: How to fill Foreign Key in a relational database when creating a new row? Pin
Alex Dunlop19-Dec-21 9:02
Alex Dunlop19-Dec-21 9:02 
QuestionWhere did i get asp.net project in linux with mysql database.? Pin
Tushar Surve 202115-Dec-21 7:11
Tushar Surve 202115-Dec-21 7:11 
AnswerRe: Where did i get asp.net project in linux with mysql database.? Pin
Richard Deeming15-Dec-21 7:22
mveRichard Deeming15-Dec-21 7:22 
GeneralRe: Where did i get asp.net project in linux with mysql database.? Pin
Mycroft Holmes15-Dec-21 14:31
professionalMycroft Holmes15-Dec-21 14:31 
QuestionTwo ReportViewers on the same project Pin
Member 1077312213-Dec-21 2:01
Member 1077312213-Dec-21 2:01 
QuestionRe: Two ReportViewers on the same project Pin
CHill6013-Dec-21 2:09
mveCHill6013-Dec-21 2:09 
QuestionAn unhandled exception occurred while processing the constructor in ASP.NET Core MVC Pin
Alex Dunlop6-Dec-21 8:51
Alex Dunlop6-Dec-21 8:51 
AnswerRe: An unhandled exception occurred while processing the constructor in ASP.NET Core MVC Pin
Richard Deeming6-Dec-21 22:54
mveRichard Deeming6-Dec-21 22:54 
GeneralRe: An unhandled exception occurred while processing the constructor in ASP.NET Core MVC Pin
Alex Dunlop7-Dec-21 8:09
Alex Dunlop7-Dec-21 8:09 
QuestionUse Active Directory for authentication Pin
Joseline Riker2-Dec-21 6:50
Joseline Riker2-Dec-21 6:50 
QuestionIs this data annotation correct for date and time? Pin
Alex Dunlop25-Nov-21 23:26
Alex Dunlop25-Nov-21 23:26 
AnswerRe: Is this data annotation correct for date and time? Pin
Richard MacCutchan26-Nov-21 1:02
mveRichard MacCutchan26-Nov-21 1:02 
GeneralRe: Is this data annotation correct for date and time? Pin
Alex Dunlop26-Nov-21 1:28
Alex Dunlop26-Nov-21 1:28 
GeneralRe: Is this data annotation correct for date and time? Pin
Richard MacCutchan26-Nov-21 1:39
mveRichard MacCutchan26-Nov-21 1:39 
GeneralRe: Is this data annotation correct for date and time? Pin
Alex Dunlop26-Nov-21 1:45
Alex Dunlop26-Nov-21 1:45 
GeneralRe: Is this data annotation correct for date and time? Pin
Richard MacCutchan26-Nov-21 1:56
mveRichard MacCutchan26-Nov-21 1:56 
AnswerRe: Is this data annotation correct for date and time? Pin
jkirkerx28-Nov-21 10:12
professionaljkirkerx28-Nov-21 10:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.