.NET Framework Detection in the Windows Registry

To determine which .NET framework is installed on the Windows computer check the values in the registry. The HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full key contains two values you can check: Release Version You can use InSpec, part of the Chef DK, to check the values: describe registry_key(‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full’) do it { should have_property ‘Release’ } it { …

Procedure or function ‘`…_Insert`’ cannot be found in database …

When you use the Microsoft .NET Entity framework to access a MySql database, the autogenerated code throws an error when you try to insert a row into the database with context.MY_TABLE.Add(MY_OBJECT); Server Error in ‘/’ Application. Procedure or function ‘`…_Insert`’ cannot be found in database ‘`…`’. Description: An unhandled exception occurred during the execution of …

No connection string named ‘…’ could be found in the application config file.

Two-tier applications separate the presentation layer and the data layer, and all database access related objects are located in the data-tier. When the application runs, the config file of the main project is read. In web applications, it is the web.config, in console applications the app.config file. When you get the following runtime exception Exception thrown: ‘System.InvalidOperationException’ in …

NotSupportedException: Unable to determine the provider name for provider factory of type ‘MySql.Data.MySqlClient.MySqlClientFactory’. Make sure that the ADO.NET provider is installed or registered in the application config

In a two-tier web application, the data layer is in a separate project. This allows better separation between the presentation layer and the data layer. This way you can reuse the data project in another application that targets the same database. To access a MySql database you need to add the MySql.Data and MySql.Data.Entity NuGet packages to …

Create an ASP.NET MVC 5 Web Application with user authentication

To create a new ASP .NET MVC web application that contains user authentication code In the File menu of Visual Studio select New, Project… On the left select Visual C#, Web, and in the middle select ASP.NET Web Application (.NET Framework) Enter the Name, select the solution folder location and click OK. The solution name …

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

When I made changes to the web.config file of an ASP.Net C# application, I have accidentally deleted a comma, and I started to get the runtime error message: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) Make sure all necessary commas are there in the config files, Visual Studio does not …

Connect to a MySQL database from Visual Studio 2017

As of today weI can connect to a MySQL database, but cannot generate the Entity Data Model from a MySQL database in Visual Studio 2017 To access a MySQL database from Visual Studio 2017 IMPORTANT: First install MySQL for Visual Studio, and after that install MySQL Connector/Net. If MySQL Connector/Net is already installed on your workstation, uninstall …

Generate Entity Framework Entity Data Model in Visual Studio 2017

Visual Studio 2017 has many project type options, and not all of them support the Entity Framework user interface to generate the Entity Framework Data Model (EDMX) file. If you create an ASP.NET Web Application(.NET Framework) you can add the EDMX file to it. The .NET Core projects do not support the Entity Framework Data Model …

{“error”:”Entity type ‘AspNetUserRoles’ has composite primary key defined with data annotations. To set composite primary key, use fluent API.”}

When a database table has composite keys (multiple columns are in the key) you cannot use the usual key definition [Key] [Display(Name = “UserId”)] public string UserId { get; set; } [Key] [Display(Name = “RoleId”)] public string RoleId { get; set; } When you run the application you get the error message: {“error”:”Entity type ‘AspNetUserRoles’ has composite …