Click here to Skip to main content
15,913,090 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to use angular along with ASP.NET mvc project Pin
Nitin S4-Jul-18 20:37
professionalNitin S4-Jul-18 20:37 
AnswerRe: How to use angular along with ASP.NET mvc project Pin
Keviniano Gayo4-Jul-18 22:05
Keviniano Gayo4-Jul-18 22:05 
AnswerRe: How to use angular along with ASP.NET mvc project Pin
Vincent Maverick Durano5-Jul-18 14:58
professionalVincent Maverick Durano5-Jul-18 14:58 
GeneralRe: How to use angular along with ASP.NET mvc project Pin
Nitin S5-Jul-18 17:52
professionalNitin S5-Jul-18 17:52 
GeneralRe: How to use angular along with ASP.NET mvc project Pin
Vincent Maverick Durano6-Jul-18 2:04
professionalVincent Maverick Durano6-Jul-18 2:04 
AnswerRe: How to use angular along with ASP.NET mvc project Pin
jkirkerx6-Jul-18 9:09
professionaljkirkerx6-Jul-18 9:09 
GeneralRe: How to use angular along with ASP.NET mvc project Pin
Vincent Maverick Durano6-Jul-18 18:43
professionalVincent Maverick Durano6-Jul-18 18:43 
GeneralRe: How to use angular along with ASP.NET mvc project Pin
jkirkerx8-Jul-18 12:20
professionaljkirkerx8-Jul-18 12:20 
QuestionAngular project Pin
Nitin S4-Jul-18 20:34
professionalNitin S4-Jul-18 20:34 
AnswerRe: Angular project Pin
Vincent Maverick Durano5-Jul-18 15:05
professionalVincent Maverick Durano5-Jul-18 15:05 
Question.Net Core 2.1 - Setting Session Value in controller, then reading it in Controller Attribute. Pin
jkirkerx4-Jul-18 8:45
professionaljkirkerx4-Jul-18 8:45 
AnswerRe: .Net Core 2.1 - Setting Session Value in controller, then reading it in Controller Attribute. [solved maybe] Pin
jkirkerx4-Jul-18 10:22
professionaljkirkerx4-Jul-18 10:22 
QuestionLoop through dataset to create hyperlinks in aspx Pin
caffrey_13-Jul-18 23:44
caffrey_13-Jul-18 23:44 
AnswerRe: Loop through dataset to create hyperlinks in aspx Pin
Richard Deeming4-Jul-18 7:37
mveRichard Deeming4-Jul-18 7:37 
PraiseRe: Loop through dataset to create hyperlinks in aspx Pin
caffrey_14-Jul-18 10:27
caffrey_14-Jul-18 10:27 
QuestionBinding selected value of Dropdownlist to Grid Pin
indian1433-Jul-18 12:58
indian1433-Jul-18 12:58 
AnswerRe: Binding selected value of Dropdownlist to Grid Pin
Vincent Maverick Durano3-Jul-18 16:20
professionalVincent Maverick Durano3-Jul-18 16:20 
Question.Net Core 2.1 IHostingEnvironment, how to access it Pin
jkirkerx28-Jun-18 20:14
professionaljkirkerx28-Jun-18 20:14 
AnswerRe: .Net Core 2.1 IHostingEnvironment, how to access it Pin
Richard Deeming29-Jun-18 0:00
mveRichard Deeming29-Jun-18 0:00 
GeneralRe: .Net Core 2.1 IHostingEnvironment, how to access it Pin
jkirkerx29-Jun-18 6:18
professionaljkirkerx29-Jun-18 6:18 
Question.Net Core 2.1, Get the Environment to seed a database so I can get the path Pin
jkirkerx28-Jun-18 9:02
professionaljkirkerx28-Jun-18 9:02 
AnswerDirectory.GetCurrentDirectory Pin
jkirkerx28-Jun-18 9:11
professionaljkirkerx28-Jun-18 9:11 
AnswerRe: .Net Core 2.1, Get the Environment to seed a database so I can get the path Pin
Richard Deeming28-Jun-18 10:26
mveRichard Deeming28-Jun-18 10:26 
The code in Startup runs as part of the BuildWebHost method in the Program class. That gets invoked both by the application, and by the design-time EF commands (add-migration, update-database, etc.), so you can't seed the data in the Startup class.
In 2.0 projects using EF Core 2.0, Program.BuildWebHost is invoked to obtain the application services. Unlike 1.x, this has the additional side effect of invoking Startup.Configure. If your 1.x app invoked database initialization code in its Configure method, unexpected problems can occur.

So the seeding code needs to be in Main, on in the context's OnModelCreating method[^].

In theory, you should be able to inject any registered service into your DbContext constructor, which would let you access your ServerPath service from the OnModelCreating method.

Alternatively, you can retrieve the services from the Main method using services.GetRequiredService<ServerPath>(); within the try block.

(Personally, I tend to keep the migrations and seed data in a separate console app, because I don't want the website connecting to SQL using an account that has permissions to create and modify databases.)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: .Net Core 2.1, Get the Environment to seed a database so I can get the path Pin
jkirkerx28-Jun-18 11:56
professionaljkirkerx28-Jun-18 11:56 
QuestionSenior MVC Full Stack Developer Job Postings with Angular Experience Pin
jkirkerx27-Jun-18 8:42
professionaljkirkerx27-Jun-18 8:42 

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.