martes, 23 de mayo de 2017

MVC Post Action Method is calling when using @Html.Action

MVC Post Action Method is calling when using @Html.Action

Please follow up the steps below to solve the issue:

1. Avoid using @Html.Action from the Layout page (shared folder)
2. If you are using Ajax calls with the POST method inside the main page, please be sure the assigned Url has a valid value, otherwise the system will load again the same page but with the post action, that's why when it loads the partial page inside the main page with the @Html.Action it is calling the Post Action method.

martes, 9 de mayo de 2017

Entity Framework - Have column in our model without including it to the database

Entity Framework - Have column in our model without including it to the database


Please see the sample below:

public class TheModelSample
{
    public int Id { get; set; }
    public string UserName { get; set; }

    [NotMapped]
    public string ConfirmPassword { get; set; }
}

viernes, 28 de abril de 2017

Entity Framework - Recreate my database

Entity Framework - Recreate my database and re-start my DB migrations

If you would like to recreate your database and start again with your migrations from scratch just follow up this simple steps:

1. Go to your MS SQL Server and delete the database
2. Go to your Visual Studio (I'm currently using VS2015) and locate your "migrations" folder and delete any migration you have (do not delete the "Configuration.cs" file if you have it.
3. Add a configuration file into your migrations folder if you don't have it by enabling migrations from the package manager console.

    Enable-migrations

4. Add or Update the AutomaticMigrationsEnabled to true
5. Run your project

Now you will see that your database was created again, if so, continue the step #6.
If you don't see the database go to step #7

6. Recreate the Initial migration by running this command from the package manager console:

    Enable-migrations -Force

   
    * If you enable migrations through step 6 then, It should not be necessary to continue with step 7


7. Run the next commands from your package manager console:

    Add-Migration InitialCreate

    Update-Database -verbose






sábado, 25 de marzo de 2017


RDLC Report - tablix column header not repeating on every page

    It is  a common problem with the tablix component in a RDLC report or basically it is just a setting we need to change.
    
    In order to change the behavior follow up the next steps:

1. open the rdlc report
2. click on the tablix component and make sure you can see the rows group and columns group window
3. Click on the small downward arrow located at the right side of the columns group window to reveal the advanced mode check box and click on it
4. Now you will see one or more additional items in the rows group list that are shown as Static 
5. Click on the "Static" item and check the "Properties" window and you will notice that you have selected a Tablix component which will have a set of properties
6. Select the "true" option of the RepeatOnNewPage property
7. Select the "after" option of the KeepWithGroup property
8. Select the "true" option of the FixedData property

Now you may try to run the project and check again. 


lunes, 13 de marzo de 2017

Error: Attaching an entity of type 'MyProject.Models.MyModel' failed because another entity of the same type already has the same primary key value

Attaching an entity of type 'MyProject.Models.SalesDetail' failed because another entity of the same type already has the same primary key value

    Basically this is happening because we have 2 objects of the same type, one getting information and other trying to update its records. We should avoid this situation in order to continue updating our model.

In my case I was doing something like below:

Sales sales = new Sales();
sales = db.Sales.FirstOrdefault(m => m.Id == MySalesId);

SalesDetail detail = new SalesDetail()
detail = db.SalesDetail.FirstOrdefault(m => m.Id == MySalesDetailId);

sales.SalesDetail.ProductId = MyProductId;                 <-- REASON

Line above should be replace for the line below:

detail.ProductId = MyProductId;

db.Entry(detail ).State = EntityState.Modified;              <-- ERROR HERE
db.SaveChanges();

************************************************************************************************

viernes, 3 de marzo de 2017

Functional Programming with F#

Functional Programming with F#

    F# is a multi-paradigm programming language and what that means is that it takes parts of different programming languages and put them together into one language that can do different types of code designs, so F# is primarily a functional programming language, it was designed for that purpose, but also it can do Object Oriented programming, so it can do things like classes, interfaces and stuff like that.
    Other interesting about F# is that it's a part of the .Net system, so it was designed to be a functional programming language that runs on .Net, so it means that it has the ability to inter-operate with C#, Visual Basic and anything else is written in .Net; the other benefit is that you actually have access to all the existing tools and the libraries that exist in the .Net world.

   Functional Programming is a style that uses functions as the basic unit of abstractions and the contrast against an object oriented language like C#, an object oriented language uses classes as the basic unit of abstraction, so you design all the application code around classes as the thing you use for encapsulation and your contracts between different sub-components of your application; with a functional language you're basically building up layers of logic using functions and then you're using some others functions that can take functions as parameters to build your abstraction and build your more complicated logic.

http://fsharp.org

martes, 28 de febrero de 2017

Cascading Style Sheets - How to clean your CSS sheets

Cascading Style Sheets - How to clean your CSS sheets

    As you add elements to your page, you may be creating new styles for them. When you change that page again, you will probably remove some of those elements, but you will rarely remember to clean up the styles you created for them.

    Make clean in the CSS file of your page is a real ordeal because it is difficult to know if a particular label is used or not in your blog.

    That's why I want to share with you this technique really useful:

How to use Dust Me Selectors to remove not used styles from your CSS sheet ?

1. First we need to install the complement (Dust-Me Selector) from your Firefox browser.
2. Restart the Firefox browser
3. Click the Dust-Me Icon and select the "Spider SiteMap" menu
4. Write the root page from which the scan will start
5. Once the process is finished you will see all the not used selectors from each CSS files

Do you have any question ?  

Please do not hesitate to ask me...



*************************************************************************************************


A medida que agrega elementos a su página, puede estar creando nuevos estilos para ellos. Cuando vuelva a cambiar esa página, probablemente eliminará algunos de esos elementos, pero rara vez recordará limpiar los estilos que creó para ellos.

     Hacer limpieza en el archivo CSS de su página es un calvario real porque es difícil saber si una etiqueta en particular se utiliza o no en su blog.

     Es por eso que quiero compartir con ustedes esta técnica realmente útil:

¿Cómo usar "Dust Me Selectors" para eliminar los estilos no utilizados de su hoja CSS?

1. Primero necesitamos instalar el complemento (Selector Dust-Me) desde su navegador Firefox.
2. Reinicie el navegador Firefox
3. Haga clic en el icono Dust-Me y seleccione el menú "Spider SiteMap"
4. Escriba la página raíz desde la cual se iniciará la exploración
5. Una vez finalizado el proceso, verá todos los selectores no utilizados de cada archivo CSS

Tienes alguna pregunta ?

Por favor, dejame un mensaje.



jueves, 23 de febrero de 2017

Entity Framework - How to add a new table to an existing database when using code first migrations

Entity Framework 
How to add a new table to an existing database when using code first migrations


Just create your new table as a model and add its entry in your DBContext class:


public class MyContext : DbContext, IDisposable
{
    public DbSet<MyModel1> Model1 { get; set; }
    public DbSet<MyModel2> Model2 { get; set; }

    public DbSet<MyNewModel> MyNewModels { get; set; }


Then Run the Add-migrations and Update-Database commands from the Package manager console

Entity Framework - Simple Steps for Migrations

Entity Framework 
Simple Steps for Migrations



Open the Package Manager Console:

From visual studio select the menu Tools-> Nuget Package Manager-> Package Manager Console

Enabling Migrations:

* Run the Enable-Migrations  command in the Package manager Console

This command has added a Migrations folder to our project, this new folder contains two files: The configuration class & An InitialCreate migration.


Generating and Running Migrations:

* Run Add-Migration AddNewColumnForMyTable command in Package Manager Console


Migrate to a Specific Version (Including Downgrade):

* Run the Update-Database -TargetMigration: AddNewColumnForMyTable command in Package Manager Console



lunes, 20 de febrero de 2017

Bootstrap - Modal appearing under background

Modal appearing under background

The problem has to do with the positioning of the parent containers. You can easily "move" your modal out from these containers before displaying it. Here's how to do it if you were showing your modal using js:


$('#theModal').appendTo("body").modal('show');
Or


$('#theModal').appendTo("body") 

viernes, 17 de febrero de 2017

Visual Studio - Web Essentials

Visual Studio - Web Essentials

Have you ever searched a way to make your life as a developer easier with the Visual Studio IDE ?

Well, let me mention you a visual studio extension named -Web Essentials-  this is for all Web developers using Visual Studio.

Please go to http://vswebessentials.com/

For a complete extension pack go to Web Extension Pack 2015


********************************************************************************************************


¿Alguna vez has buscado una forma de hacer tu vida como desarrollador más fácil con el IDE de Visual Studio?


Bueno, permíteme mencionarte una extensión de estudio visual llamada -Web Essentials- esto es para todos los desarrolladores web que usan Visual Studio.

Para mayor referencia accede a http://vswebessentials.com/

Paquete completo de extensiones para visual studio 2015 Web Extension Pack 2015

jueves, 16 de febrero de 2017

Visual Studio 2015 HttpHostx64.exe has stopped working


Visual Studio 2015 HttpHostx64.exe has stopped working

I started having the error above frequently after I installed the Update 3 for Visual Studio 2015... 

The crashing file is located in the folder below:

C:\Program Files (x86)\Common Files\Microsoft Shared\VsHub\1.0.0.0 

How to fix?

1. Close Visual Studio if started.
2. Rename Microsoft.VsHub.Server.HttpHostx64.exe  to  Microsoft.VsHub.Server.HttpHostx64.exe.bak   
3. Create a copy of Microsoft.VsHub.Server.HttpHost.exe and rename it Microsoft.VsHub.Server.HttpHostx64.exe    
4. Re-start Visual Studio

The issue has been reported and a thread is available here:



miércoles, 8 de febrero de 2017

Visual Studio 2015 has stopped working and restarting

Visual Studio 2015 has stopped working & restarting
The Javascript Language service is processing your request in the background


    Recently something happened with my Visual Studio 2015, it started to restart the IDE. In my particular case I noticed the issue while I was writing some Javascript code and unexpectedly I saw an error message about my IDE was restarting and another message in the status bar like:

The Javascript Language service is processing your request in the background.


I follow up the next steps to solve the issue:



  • Go to the Scripts folder or whatever you may find the _references.js file 
  • Delete all the content inside



*********************************************************************************

    Recientemente me sucedió este tener este problema cuando estaba trabajando con el Visual Studio 2015, en mi caso en particular lo note mientras trabajaba con código de Javascript cuando de repente me aparecio un mensaje de que mi Visual Studio se estaba reiniciando y en la barra de estado decía el siguiente mensaje:

The Javascript Language service is processing your request in the background.


para resolver el problema encontré los siguientes pasos:




  • Ir al folder "Scripts" o busca el archivo _references.js
  • Borra el contenido del archivo