Saturday, November 19, 2016

HTML Block-level Elements

Elements in HTML are either block-level or inline. A block-level element occupies the entire space of its parent element (container), thereby creating a block. Browsers typically display the block-level element with a newline both before and after the element. You can visualize them as a stack of boxes. Refer to the following link for more information.


<address>         Contact information.
<blockquote> Long ("block") quotation.
<dd>         Definition description.
<div> Document division.
<dl> Definition list.
<fieldset> Field set label.
<form> Input form.
<h1>, <h2>, <h3>, <h4>, <h5>, <h6> Heading levels 1-6.
<hr> Horizontal rule (dividing line).
<li> List item.
<main> Contains the central content unique to this document.
<nav> Contains navigation links.
<noscript> Content to use if scripting is not supported or turned off.
<ol> Ordered list.
<p> Paragraph.
<pre> Preformatted text.
<q> Short quote.
<table> Table.
<tfoot> Table footer.
<ul> Unordered list.


HTML 5 Block-level elements.

<article> Article content.
<aside> Aside content.
<canvas> Drawing canvas.
<figcaption> Figure caption.
<figure> Groups media content with a caption.
<footer> Section or page footer.
<header> Section or page header.
<hgroup> Groups header information.
<output> Form output.
<section> Section of a webpage
<video> Video player.


Video player.

Wednesday, November 16, 2016

HTML Web Server for Angular Research/Study

My recommendation is to use the http-server module of Node.js. Node.js is available cross-platform and can be installed fromhttp://nodejs.org/Once Node.js is installed, installing the http-server module and running the http server are easy. Open the command line and type the following command:

npm install http-server –g

This installs the HTTP server at the global level. To run the server, just navigate to the folder where the app code resides, or open the folder from where we want to serve static files, and type this:

http-server

You will have an HTTP server running at http://localhost:8080 that can serve files from the current directory.

To run the server on port 80 so you don't have to append the port every time you start the server type this:

sudo http-server -p 80

You will not have an HTTP server running on http://localhost that can serve files from the current directory. Note we used sudo in the case above as most systems wouldn't allow you to work with port 80. You'll need to be in the sudoers file to be able to access sudo.


The http-server module does support some startup configurations. Check the documentation at https://github.com/nodeapps/http-server.


Tuesday, November 15, 2016

Diff Files in Visual Studio

You can invoke devenv.exe /diff list1.txt list2.txt from the command prompt or, if a Visual Studio instance is already running, you can type Tools.DiffFiles in the Command window, with a handy file name completion:
Using Tools.DiffFiles from Visual Studio Command window

Entire article is on StackOverflow
http://stackoverflow.com/questions/13752998/compare-two-files-in-visual-studio-2012



7
Does this diff tool provide any useful feature like copy to left, copy to right, etc? When I diff working copy with the server version I sometimes wish to undo some of the changes and has to do manual copy pasting. – Samuel Feb 12 '14 at 10:24
54
Why is this feature hidden from the VS UI ? This is the easiest and effective way of comparing two files... – eka808 Feb 14 '14 at 15:23
4
If your path has spaces, you can wrap either the entire path or just the part part with spaces in quotes. – pennstatephil Jun 24 '14 at 15:16
40
For those of you who are new to Visual Studio the Command Window can be opened by going to: View > Other Windows > Command Window (VS Pro 2013) or with CTRL+ALT+A – Cleanshooter Jun 26 '14 at 13:30
12
such a shame VS doesn't have a menu item for this very basic functionality. many IDE's/ editors do. – dewdSep 16 '14 at 9:09


Sunday, May 1, 2016

Apple - Running Questions

Upgraded my MacBook Pro last week to El Capitan.  So far I'm struggling to keep a positive attitude.  My issues follow.


     1) My laptop can now take longer than 30+ minutes to book, and in same cases I have to power off the machine and then power it back on in order to be able to log in.


     2) My Time Machine backups are now acting  up as well.  I want to get a couple of "good" backups before I completely format my machine and re-install the os.  However, my backups start and now never finish.  I'd replaced my existing external drive with a different one and when it runs it's not registering anywhere near the same size of the files as I have I disk.  This makes me question my backups.  I attempted to just do a file copy to an external drive and that fails saying that my file name is too long or I have an illegal character.


Bottom line, I used my system for work and this upgrade has really cost me confidence, time, and money.  Worse still, I haven't resolved my issues so I'm not up and running yet...

Wednesday, April 27, 2016

Entity Framework - Running Questions

The following are questions I am encountering.  I will provide answers when I discover them.  Please feel free to comment and provides answers/thoughts.


1) Unable to execute Entity Framework Add-Migration with changes after the initial Add-Migration

Hopefully, my title is not as confusing as my explanation!!! <grin> I'm new to the Entity Framework and ran into a very interesting issue.  I assume it's due to my lack of knowledge, but just in case it isn't I thought I'd document my issue and "work-around"/solution.

I'm running Visual Studio 2012 with Entity Framework 6.1.  I'm using the Code First from Database as my approach.  My SQL Server database had about 25 tables.  I was just trying to use the Code First from Database approach to obtain my POCO classes for my database objects and the db context class that Entity Framework should "auto-majically" create for me.

I created a simple console application and then used the reverse engineer code first.

Right click on the project name
--> Entity Framework
     --> Reverse Engineer Code First


Provide the appropriate server and database name.  The Entity Framework will now create your POCO classes (usually under a Models folder in your solution.  Additionally, it will create mapping classes under a Mapping sub-folder of the Models folder.  It will also create a database context class (by deafult named "databasenameContext") in the Models folder.

Now I opened the Package Manager console and enabled migrations for my project.

PM> Enable-Migrations
Checking if the context targets an existing database...
Code First Migrations enabled for project ConsoleApplication5.
PM>

Next I obtained my base-level migration snapshot of my database

PM> Add-Migration v1.00
Scaffolding migration 'v1.00'
The designer Code for this migration file includes a snapshot of your current Code First model.  This snapshot is used to calculate the changes to your model when you scaffold the next migration.  If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration v1.00' again.
PM>

Now I assumed all I needed to do was make changes in my POCO classes and then run another Add-Migration to pick up the changes and get them applied to my database.  WRONG!!!

I went to one of my POCO classes and just added a new column.  A super tiny change, i.e.

public string testcolumn2 { get; set; }

PM> Add-Migration v1.01
Unable to generate an explicit migration because the following explicit migrations are pending:  [201602080605348_v1.00].  Apply the pending explicit migrations before attempting to generate a new explicit migration.
PM>

Well, I tried applying the 201602080605348_v1.00 migration with the Update-Database command, but that also generated an error.  The only way I found that I could create a new migration with my changes and get them applied was to do the following.

1) Copy my base migration, i.e. the one that apparantly been applied, 201602080605348_v1.00.cs, to a simple text file for safe keeping.  The 201602080605348_v1.00.cs was in the Migrations folder of the project.

2) Replace the text in the 201602080605348_v1.00.cs with the following, i.e. just adding the column.  Note you may have to change the namespace like I did if you are doing this multiple times.  <grin>

namespace ConsoleApplication5.Migrations
{
     using System;
     using System.Data.Entity.Migrations;

     public partial class v100 : DbMigration
     {

          public override void Up()
          {
               AddColumn("dbo.board", "testcolumn2", c => c.String());
          }

          public override void Down()
          {
               DropColumn("dbo.board", "testcolumn2");
          }
     }
}

3) Now run the Update-Database command from the Package Manager console.

PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied
to the target database.
Applying explicit migrations: [201602080605348_v1.00].
Applying explicit migration: 201602080605348_v1.00.
Unable to update database to match the current model because there are
pending changes and automatic migration is disabled. Either write the
pending model changes to a code-based migration or enable automatic
migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to
true to enable automatic migration.
You can use the Add-Migration command to write the pending model
changes to a code-based migration.

PM>


4) Now goto your database, I used SQL Server Management Studio, SSMS, and remove the column from the database table.  Even though we got this error message, the operation/command still modified the database.  We want to remove the column so we can run the entire process from within the Entity Framework so that all will be in synch.

5) Copy back the original/base migration text that you had copied to the text file and save it.

6) Now re-run the Add-Migration command from within the Package Manager console to pick up the new change.

PM> Add-Migration v1.01
Scaffolding migration 'v1.01'.
The Designer Code for this migration file includes a snapshot of your
current Code First model. This snapshot is used to calculate the
changes to your model when you scaffold the next migration. If you
make additional changes to your model that you want to include in this
migration, then you can re-scaffold it by running 'Add-Migration
v1.01' again.

PM>


Notice the new migration file that was added under the Migrations folder in the project.

7) Now run the Update-Database command still from within the Package Manager console to apply the changes and synch both the Entity Framework and your database.


References

https://msdn.microsoft.com/en-us/data/aa937723
https://msdn.microsoft.com/en-us/data/jj591621.aspx


2) Why when using EF Code First and Reverse Engineering an existing database do I get two constructors in my context class?  I believe in the example below the first is ensuring my database is not recreated as I am connecting to an existing database, SixteenthSectionLegacy, and the second is identifying the connection string that is used in my app.config file...


using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using EFReverseEngineerTest.Models.Mapping;

namespace EFReverseEngineerTest.Models
{
    public partial class SixteenthSectionLegacyContext : DbContext
    {
        static SixteenthSectionLegacyContext()
        {
            Database.SetInitializer<SixteenthSectionLegacyContext>(null);
        }

        public SixteenthSectionLegacyContext()
            : base("Name=SixteenthSectionLegacyContext")
        {
        }

        public DbSet<board> boards { get; set; }
        public DbSet<BOARD1> BOARDS1 { get; set; }
        public DbSet<Classification> Classifications { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new boardMap());
            modelBuilder.Configurations.Add(new BOARD1Map());
            modelBuilder.Configurations.Add(new ClassificationMap());
        }
    }
}


3) Where you look for errors in entity framework code first reverse engineer?  I am reverse engineering a very large database and found tables missing.  Upon investigation I did find several that were missing primary keys.  I'm trying trying to determine why the others were not created.  Where can I look for errors, i.e. log file, etc.?


4) Attempting to use Code First with an existing database.  Having issues with not all of the tables being imported as the primary key's don't follow the expected naming conventions so that EF can recongnize/identify the primary key.  With a large number of tables it is not feasible to have to manually create all the POCO's so how can I get EF to import all the tables and create the base POCO's so that I can go in and tweak them after the fact???

Sorry for the Delay - Back on track, Microsoft's Entity Framework

Okay, so it's been awhile since I've blogged.  In addition to software development I own a small Beekeeping business and Spring is one of the craziest times of the year for beekeepers.  I've been working 90+ weeks for the past four weeks between my software gigs and bees so as you can see I've had very little time to keep my blog updated.

I'm currently working two different projects for two different organizations in which I'm using Entity Framework The first project is actually part of an application migration in which legacy data is being extracted from several legacy databases and being migrated/transitioned into an existing production database.  This project is using code first for the development and testing portions of the project. The second project involves using a WCF service which uses EF.  This second project allows me to define and create the both the domain class and database tables as I see fit.    Hopefully, I'll have a decent handle on EF after these two projects.

As I've been busy and focused on other work/projects I'm having to catch-up and remember where I left off on the first project. To help jog my memory I'm reviewing O'Reilly's Programming Entity Framework: Code First. Two other O'Reilly references that I will use, but haven't yet, are - Programming Entity Framework (2nd Edition) and Programming Entity Framework: DbContext.

For me, I need to remember the following definitions from the first couple of chapters.


  • Domain Class - My application's object classes

  • DbContext - Makes code first "aware" of my domain classes, wrapper around ObjectContext

  • DbSet - Wrapper around ObjectSet

  • EDMX - model XML, database XML, Mapping XML



Sunday, April 24, 2016

Loading data into SQL Server that has Carriage Returns, Line Feeds, and Commas

1) Run someting like the following to generate your data set.  Note the end result will be a text file that is bar, |, delimited.

SELECT CONCAT(
number,
'|',
CONVERT(VARCHAR, [begin]),
'|',
REPLACE ( descript , CHAR(13) + CHAR(10) , ' ' ), -- AS descript,
'|',
REPLACE ( Notes , CHAR(13) + CHAR(10) , ' ' ), -- AS Notes,
'|',
REPLACE ( s_notes , CHAR(13) + CHAR(10) , ' ' )) -- AS s_notes
FROM stage.LeaseDuplicates;

2) Save the data set as a text file.

3) Import into Excel selecting the bar, |, as the delimiter.

Friday, February 12, 2016

Incognito

Prevent tracking of where you've browsed in Chrome by using Incognito.  I've used this while troubleshooting application issues.  Read more at the following link.

Unable to execute Entity Framework Add-Migration with changes after the initial Add-Migration


Hopefully, my title is not as confusing as my explanation!!! <grin> I'm new to the Entity Framework and ran into a very interesting issue.  I assume it's due to my lack of knowledge, but just in case it isn't I thought I'd document my issue and "work-around"/solution.

I'm running Visual Studio 2012 with Entity Framework 6.1.  I'm using the Code First from Database as my approach.  My SQL Server database had about 25 tables.  I was just trying to use the Code First from Database approach to obtain my POCO classes for my database objects and the db context class that Entity Framework should "auto-majically" create for me.

I created a simple console application and then used the reverse engineer code first.

Right click on the project name
--> Entity Framework
     --> Reverse Engineer Code First


Provide the appropriate server and database name.  The Entity Framework will now create your POCO classes (usually under a Models folder in your solution.  Additionally, it will create mapping classes under a Mapping sub-folder of the Models folder.  It will also create a database context class (by deafult named "databasenameContext") in the Models folder.

Now I opened the Package Manager console and enabled migrations for my project.

PM> Enable-Migrations
Checking if the context targets an existing database...
Code First Migrations enabled for project ConsoleApplication5.
PM>

Next I obtained my base-level migration snapshot of my database

PM> Add-Migration v1.00
Scaffolding migration 'v1.00'
The designer Code for this migration file includes a snapshot of your current Code First model.  This snapshot is used to calculate the changes to your model when you scaffold the next migration.  If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration v1.00' again.
PM>

Now I assumed all I needed to do was make changes in my POCO classes and then run another Add-Migration to pick up the changes and get them applied to my database.  WRONG!!!

I went to one of my POCO classes and just added a new column.  A super tiny change, i.e.

public string testcolumn2 { get; set; }

PM> Add-Migration v1.01
Unable to generate an explicit migration because the following explicit migrations are pending:  [201602080605348_v1.00].  Apply the pending explicit migrations before attempting to generate a new explicit migration.
PM>

Well, I tried applying the 201602080605348_v1.00 migration with the Update-Database command, but that also generated an error.  The only way I found that I could create a new migration with my changes and get them applied was to do the following.

1) Copy my base migration, i.e. the one that apparantly been applied, 201602080605348_v1.00.cs, to a simple text file for safe keeping.  The 201602080605348_v1.00.cs was in the Migrations folder of the project.

2) Replace the text in the 201602080605348_v1.00.cs with the following, i.e. just adding the column.  Not you may have to change the namespace like I did if you are doing this multiple times.  <grin>

namespace ConsoleApplication5.Migrations
{
     using System;
     using System.Data.Entity.Migrations;

     public partial class v100 : DbMigration
     {

          public override void Up()
          {
               AddColumn("dbo.board", "testcolumn2", c => c.String());
          }

          public override void Down()
          {
               DropColumn("dbo.board", "testcolumn2");
          }
     }
}

3) Now run the Update-Database command from the Package Manager console.

PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied
to the target database.
Applying explicit migrations: [201602080605348_v1.00].
Applying explicit migration: 201602080605348_v1.00.
Unable to update database to match the current model because there are
pending changes and automatic migration is disabled. Either write the
pending model changes to a code-based migration or enable automatic
migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to
true to enable automatic migration.
You can use the Add-Migration command to write the pending model
changes to a code-based migration.

PM>


4) Now goto your database, I used SQL Server Management Studio, SSMS, and remove the column from the database table.  Even though we got this error message, the operation/command still modified the database.  We want to remove the column so we can run the entire process from within the Entity Framework so that all will be in synch.

5) Copy back the original/base migration text that you had copied to the text file and save it.

6) Now re-run the Add-Migration command from within the Package Manager console to pick up the new change.

PM> Add-Migration v1.01
Scaffolding migration 'v1.01'.
The Designer Code for this migration file includes a snapshot of your
current Code First model. This snapshot is used to calculate the
changes to your model when you scaffold the next migration. If you
make additional changes to your model that you want to include in this
migration, then you can re-scaffold it by running 'Add-Migration
v1.01' again.

PM>


Notice the new migration file that was added under the Migrations folder in the project.

7) Now run the Update-Database command still from within the Package Manager console to apply the changes and synch both the Entity Framework and your database.


References

https://msdn.microsoft.com/en-us/data/aa937723
https://msdn.microsoft.com/en-us/data/jj591621.aspx

Monday, January 18, 2016

How to remove a solution from Visual Studio 2012.

I was attempting to do something I felt was pretty easy today, i.e. I wanted to just delete an entire solution from Visual Studio 2012.  I assumed I'd be able to just highlight the solution, do a right mouse click or maybe just select Delete from the Edit menu --WRONG!!!  I was absolutely flabbergasted/astonished.  Several posts I hit on the internet indicated that's all I should have to do, but for the life of me my specific instance of Visual Studio wouldn't all me to do it that way...  I spent way too much time looking for this answer and never found it.

My "hack" was just to close the solution and then delete it as the os level where all my Visual Studio projects were stored.  This is probably the wrong way to do it, but it's what I did.

Now time to move out and draw fire, huah...


Please disregard all the chaos on my blogs.  I've got three, Thoughts from the Dark Side - iOS Tips and Tricks, Thoughts from the Dark Side - SQL Server Notes and Tips, and Thoughts from the Dark Side - Javascript Notes, and unfortunately I've done a terrible job at keeping them updated, current, etc.  I'm going to be consolidating into a single blog over the next week or two as I'm really doing alot of cool stuff and need to be get better NOW at documenting and sharing.

Moving forward I'll be trying to document notes/issues that I encounter or anything else I think would be cool to share.  Forgive me as I'll be concentrating more on the actual content and not it's presentation.