Skip to main content

Posts

Verify database prior to data insertion via EF

Recently, one of my colleague got a requirement on inserting data into database using EF. His issue was, how to verify if the database schema is proper or say all the columns in the tables matches with his POCO entities. Hope few of you must have come across similar scenarios. Here is the quick solution for this. In such scenarios, developers can do the schema compatibility check prior to inserting any data into the columns to ensure that model class still holds good with database tables. bool isModelValid = yourContext. Database . CompatibleWithModel ( true ); In the above method, passing the correct boolean value will do the trick for us. If the parameter value passed is true, then the framework will throw an exception if the schema doesn’t matched with your model class. Isn’t it a useful tip? Happy troubleshooting!!!

Ways to add dependency packages in .NET core

This would be a very short article on how to add dependencies in .Net Core . Well, there are many ways to achieve this. One is via Visual Studio and another way is through command prompt. Let’s quickly have a look.  1) From Visual Studio:  This is the straight forward way for the ones who want to use user interface to add dependencies. Right click on your project/library and get it from Nuget gallery.  2) From Command Prompt:   If you are a command prompt fan, then there itself, you have 2 choices. A) Open command prompt. Navigate to your project directory and simply fire: C:\<Your project directory> dotnet add package Microsoft.AspNetCore   B) Alternative you can go and add the reference directly in .csproj file as shown below: and restore it from command prompt using very simple command: C:\<Your project directory> dotnet restore Happy learning!!!

What and How of Requirement Gathering - Part 3

In continuation to my previous post , I’ll add some more techniques which can be used for information gathering.  Prototyping:   Prototyping allows to gather information by faking the production environment. In this technique, quite a lot of tools can be used to collect information, such as software programs to monitor/record mouse clicks or keystrokes, camera to monitor visual activity, etc.  Basically, what type of tool should be used is solely depend upon what type of information you want to collect. The cost of prototyping might be high because information gathered from this approach can be easily validated with a reason that prototyping is experimental rather than the responses received from users.  Note : Prototyping is preferred in the scenarios where it is impossible to shadow a person. Prototype can help you to get below sort of information:  Use of technologies, tools and applications.  Verification of workflow.  Cu...

What and How of Requirement Gathering - Part 2

In continuation to my previous post, I’ll add some more techniques which are popularly used for information gathering. Interviewing : While on one hand shadowing provides an effective means to discover what is currently being done in the business, but on the other hand it does not provide all the necessary information. Another flaw of shadowing would be, it is not suitable for getting information about long-term activities that extent weeks or months along with the processes that requires very less or no human intervention. Hence, we can look for other techniques like interviewing. Interviewing someone is the one-on-one meeting between project team and the user. Here quality of information totally depends upon interviewee and the interviewer. The interviewer can ask a wide range of questions as compared to shadowing mechanism. These questions can be from basic information to difficulties to limitations of the system. During the interview process, the interviewee can give some i...

What and How of Requirement Gathering - Part 1

This time rather than writing on some technology or solution, I thought to write on one of the important phases of SDLC which is nothing but requirement gathering. To be more specific, this article will be more about collecting information about business requirement. What are the various sources to get and understand most of the portions of any business requirement. It’ very important to understand that, information can be gathered from many standpoints. It can be from Business front, Application front, Operations front, Technology front , and may be many more. So, while gathering information, one should have a clear vision on what kind of information they are looking for. Let’s have a look at few of the well-known categories: B usiness – Goal of business, Service offerings, Products, Financial Structure, etc. Application – Productivity tools, interaction with business application system, Code Modules, etc. Operations – Identify the information’s origin, information’s consump...

Generating XML Root Node having colon - via Serialization

Recently I got a requirement to generate an XML on the fly with some defined schema. I know this requirement looks very simple in first sight, but actually it was not. The XML which was to be generated was having a very specific format as it was supposed to be the input for some 3 rd party tool. So, it means, it should be fully compliant with the prescribed XML node structure. Just have a look at the below schema: <sl:RandomWindow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sl="http://www.ShwetaBlogs.com/Window" xsi:schemaLocation="http://www.ShwetaBlogs.com/Window wwRandomWindow.xsd">   <Title>First Window</Title>   <Border>Single</Border> </sl:RandomWindow> Below are the classes I created for serialization purpose: By using the XmlElement and XmlAttribute classes I was able to generate most of the required parts of the XML as shown below:   But the only th...

The SDK ‘Microsoft.NET.Sdk.Web’ specified could not be found

If you are working on Visual Studio 2017 with update 3, then you might have come across the error 'The SDK ‘Microsoft.NET.Sdk.Web’ specified could not be found' in netcoreapp1.1 for both web and console. Unfortunately, I also landed up into this situation. So, one straight forward and temporary solution could be to edit the project file manually from Project Sdk = ”Microsoft.NET.Sdk.Web” to Project Sdk = ”Microsoft.NET.Sdk” and re-open the solution. Everything will work fine as expected. So, what are the reasons behind this error? I explored many articles on MSDN forums as well as looked at github link and the primary reasons which are causing this error are: Workstation is still holding an old preview version of CLI 1.0 Installed CLI version is correct but its path is incorrect. Solution : Uninstall all the older versions of CLI with 1.x as SDKs with version 1.x can break things Verify the value of PATH- Open the developer command prompt and verify the value o...