Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Wednesday, December 20, 2017

Entity Framework Core 2 - not recognizing context for Core library

I'm used to having my EF entities in separate class library and having one solution just for this library and a unit-test project. It makes development much faster (quick compilation). After switching to EF Core (2), I ran into issue that migrations won't pick up DbContext and nothing would happen. So I tried running "Get-DbContext", which resulted in nothing - not even a message in the PMC console.
Interestingly enough, exactly the same code was working fine when the project type of the library was "Class Library (.NET Standard)" instead of "Class Library (.NET Core)".
After many experiments I figured out a way to make it work. It seems that it needs an "application" to be present in the solution for the migrations to work - could be web or console.
So, to fix this issue:

  1. Add "Console App (.NET Core)" to your solution
  2. Add EF Core nuget packages to the console app
  3. Reference your class library from the console app
  4. COMPILE!!
  5. Done - now you can generate migrations (don't forget to set your console app as a "StartupProject" either through parameter or in the PMC combo at the top)


Monday, December 27, 2010

VS2010 and TFS credentials

VS2010 for some reason doesn't save TFS credentials if you connect to the TFS server. Under Win7 there's a trick that you can use to fix this:

Open up the user credentials (this is for Windows 7): Control Panel\User Accounts and Family Safety\Credential Manager
To the right of the Windows Credentials title is "Add a Windows credential". Click that link.
In the "Internet ro network address (e.g., myserver, server.company.com) box put: tfs
In the User name, put: DOMAIN\username (your username)
In the password, your password.

The whole description is here.

Tuesday, November 30, 2010

IE8 wrong style rendering on IIS / ASP.Net Dev server

I've ran into issues when site renders perfectly in VS's ASP.Net Dev Server on IE8, but when published to IIS, some styles are messed up. To make it even more confusing, it renders correctly when displayed locally on the web server and incorrectly when accessed from different machine.
Apparently I'm not the only one having this issue - and the solution is simple. Let IE know that the page should be rendered in correct mode.

Solution 1 - add following to the 'head' tag of the page:
<meta http-equiv="X-UA-Compatible" content="IE=8" />

Solution 2 - add this section to the web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

The detailed description from Microsoft is here.

Wednesday, February 25, 2009

Dev Tools

I stumbled upon interesting list of tools for developers : 20 Must-have free tools
I actually agree with most of the list, but have 2 interesting which i'm going to check out soon:
1) Doxygen - for generating documentation
2) KDiff - code merge tool as i'm still not completely happy with DiffMerge
Oh, and Pixy has released new version of his online Color Scheme Designer - priceless!

Friday, September 05, 2008

Diff tool for C# source code

The diff tool which is part of VS 2005 (TFS) is very basic and any complex diff is impossible to resolve in it.
This page has a nice list of tools available:
http://codebetter.com/blogs/patricksmacchia/archive/2008/04/28/diff-tools-to-see-source-files-changes.aspx

I used to use Araxis long time ago and it was brilliant. I'll check out WinMerge and DiffMerge now to see if free tool can do the trick. Will post more info here once I'm done evaluating.

Thursday, October 11, 2007

Debugging in VS2005 using NUnit

As I'm using NUnit more and more (i really started to fall in love with the whole unit-test concept), i find it sometimes useful to be able to debug while running the unit-test. Turns out to be quite easy. This is how it's done:
1) Put your unit-tests into separate project (I do that anyway to keep the NUnit out of "live" references) and compile it (make it either exe or dll, no difference).
2) Start NUnit, browse the compiled dll/exe (from step 1), select "File -> Save as" and save the nunit project. I typically save it in the project's root as "myproject.nunit".
3) Open the project's properties, "Debug" tab.
4) Set "Start Action" to "Start external program:" and browse the "nunit.exe" (e.g. c:\program files\nunit 2.4.1\bin\nunit.exe)
5) Set in the "Start Options" the "Command line arguments" to point to the nunit project you created in step 2. If you did the same as me, i.e. saved it in the project's root, the path should be something like "..\..\myproject.nunit"

And that's it! Just run the debug with F5 as usuall and it'll open NUNIT environment. Set break-points wherever you need in the code and run the appropriate test...

Monday, October 08, 2007

VS 2005 - error while loading form into designer

I get this error quite frequently:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.


Aparently, it's a problem in VS and there's a hotfix available for it. Restarting studio works as well, which is what I do.