Programming Archives - Digital Tool Factory blog

The Digital Tool Factory Blog

How to fix the entity framework problem with System.Data.Entity.Migrations.Utilities.DomainDispatcher not found.

After much searching and repair, I could not find a good way – the error does seem to be documented on Github – so at least there’s that.

My solution to the problem, after trying several other ways, was to downgrade Visual Studio as described here – note – you really do have to run all of the cleanup tools.

UPDATE ON 09/21/2018 – this fixes the problem – thank you Stack Overflow User.

Update on 05/02/2019 – this affects Visual Studio 2019 as well – one thing to note, this is the path to the new file
C:\Users\WarHorse\AppData\Local\Microsoft\VisualStudio\16.0_181cd91f

Copy and paste this

<dependentAssembly>
<assemblyIdentity name=”System.Management.Automation” publicKeyToken=”31bf3856ad364e35″ />
<bindingRedirect oldVersion=”0.0.0.0-3.0.0.0″ newVersion=”3.0.0.0″/>
<publisherPolicy apply=”no” />
</dependentAssembly>


24
Aug 18


Written By Steve French

 

How to fix the problem of undeletable characters in json strings in Visual Studio

So – you’re cruising around in web services, pulling data from various sources and your want to deserialize a string into an object, however, you can’t seem to remove extra quotations and escape characters. In fact everything you see looks like this

“{\”DataThingObject\”:{\”DataThingOneID\”:89,\”Status\”:\”Active\”,\”UserId\”:89,

and the \ and ” don’t go away, no matter how much text manipulation you do.

There actually isn’t a problem, you’re just looking at the string in the debugger, which adds the escape charachters for some reason – if you save it to a text or json file you will see that your json files are perfectly formatted.


06
Jul 18


Written By Steve French

 

How to fix problems with Edit and Continue in Visual Studio 2017

For quite a while I’ve been trying to use the “Edit and Continue” feature of Visual Studio 2017, but kept on getting the warnings

  • attached to a process that does not support edit and continue
  • the code being debugged was optimized
  • intellitrace events and call information is enabled
  • the .net runtime this program is running on does not support edit and continue

So, on a whim, I uninstalled Stackify Prefix and voila!  Edit and Continue is now working just fine.


30
Nov 17


Written By Steve French

 

What to do when your web.release.config does not transform in Visual Studio 2015

Make sure that you are building in release mode – i.e. go to Build => Configuration Manager, and make sure that the relevant project is set to “Release” (like below)


03
Feb 17


Written By Steve French

 

How I explain Paul Graham’s Maker schedule and Manager schedule without being insulting

'Day [009]  Schedule.' photo (c) 2010, Sadie Hernandez - license: http://creativecommons.org/licenses/by/2.0/One of Paul Graham’s most useful insights has been his Maker Schedule vs Manager Schedule. Go ahead and read the link if you’re not familiar with the concept.

It is

  • True
  • Useful
  • Deep
  • and very hard to explain to people without being insulting

By singleing yourself out as a “maker”, and hence on a “Maker Schedule” you run the serious risk of alienating all of your equally smart colleagues who have different interests and work responsibilities.  Coders, designers and artists will understand it immediately, but if you’re not one of those people it can sound like you’re putting yourself on a pedestal.

Remove Maker Schedule and Manager Schedule from the description

Just remove the job description, and substitute the noise that you’re making, which implies the type of work that you’re doing.

If you’re producing mouse clicks, you’re doing manager work, and you’re on a manager schedule.  If you’re producing keyboard clicks, you’re doing maker work, and you’re on a maker schedule.  The work is being labeled, not the person.  No one is categorized as “creative” or “business people”, it’s just the work you happen to be doing at the time.

I’ve found that people understand this instantly and intuitively.  No need to explain “Flow” or why interruptions cost so much time.  People can relate to the fact that (usually) work involving the keyboard just takes longer than work involving the mouse, and no one is inadvertently put down by being implicitly labeled.

That’s worked for me anyway.


18
May 12


Written By Steve French

 

How to programatically set the sql server database used by entity framework

The Problem:

'Entity Framework' photo (c) 2009, SondreB - license: http://creativecommons.org/licenses/by/2.0/For one reason or another you need to set the database used by entity framework programatically.  The more common way of doing such a thing is to set the database in your web.config class, but for whatever reason you need to set it in actual C# code.

The Cause:

There is no cause really, it is merely the way that entity framework and sql server work together.

The Solution:

The answer lies in setting the constructor properly.

Example Code Using Entity Framework and Data Context

using System.Data.Entity;

namespace MyDBServerExperiments.Models
{
public class DTFContext : DbContext
{
public DTFContext() : base(“Data Source=MyDBServer.DBServer.com;Initial Catalog=MyEntityFrameworkDB;Persist Security Info=True;user id=MyUsername; Password=MyPassword;”) { }

public DbSet<User> Users { get; set; }
public DbSet<BusinessObjects> BusinessObjects { get; set; }
public DbSet<Property> Properties { get; set; }

}

}

The above would be your data context file that uses the DBContext file  in your models folder, just fyi (that is the common place for Entity Framework models in the standard  Visual Studio 2010 web solution structure).

Note, everything happens in the constructor.  This give you many interesting opportunities to programatically swap out Sql Server database names and users, compared to the web.config option, which tends to be far more static.  It allows far more extensive use of business objects and


24
Apr 12


Written By Steve French

 

How to fix problems with Linq to Xml Namespaces

The Problem

You are trying to read data out of a standard xml file.  I found a great Linq to Xml tutorial here.  You get code that looks something like this

XDocument data = XDocument.Load(HttpContext.Current.Server.MapPath("~/Invoices.xml"));
List<Invoice> lst = new List<Invoice>();
lst= (from c in data.Descendants("invoice")
select new Invoice
{
ClientName = c.Element("client").Value,
InvoiceDate = Convert.ToDateTime(c.Element("date").Value),
}).ToList();

and you get nothing but object type no found errors.  Why?  You have problems with linq to xml namespaces.

The Cause:

The xml file you are trying to read is using a NameSpace!

The Solution:

Add in the namespace declaration and append it to the file in the right places, your code should look something like the below.

XDocument data = XDocument.Load(HttpContext.Current.Server.MapPath(“~/Invoices.xml”));
XNamespace ns = XNamespace.Get(“http://www.SomeProvider.com/api”);
List lst = new List();
lst= (from c in data.Descendants(ns + “invoice”)
select new Invoice
{
ClientName = c.Element(ns + “client”).Value,
InvoiceDate = Convert.ToDateTime(c.Element(ns + “date”).Value),
}).ToList();

Do you see the “ns + ” part?  That tells C# to keep your data and the xml data apart.  And please note, you have to use it everywhere you reference a part of the xml document (I spent an hour finding that out).

That’s it!  Happy Coding.


05
Feb 12


Written By Steve French

 

No one ever told me that making WordPress themes would be this easy

Had I known, I would have started years ago…


17
Jan 12


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.