Add the following constructor, which will allow configuration to be passed into the context by dependency injection.So, we need to move database provider configuration there. In ASP.NET Core, things like dependency injection, services that are going to be used, generally configured in Startup.cs class. We’ll also rename our context to OrderContext.cs and Orders.cs to Order.cs since it’s more logical that way. Now we need to add a Data folder and put our context there to conform with the separation of concerns pattern. The context represents a session with the database and allows you to query and save instances of the entity classes. The entity classes are simple C# objects that represent the data you will be querying and saving. The reverse engineering process created entity class Orders.cs, and a derived context orders_databaseContext.cs based on the schema of the existing database. Scaffold -DbContext "Server=localhost\SQLEXPRESS Database=orders_database Trusted_Connection=True " Microsoft.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |