Error while trying to connect to Team Foundation Server 2011 Express

I have just installed TFS Express 2011 Beta and try to use it. First thing I do is create a new Team Project to add some source code. It worked perfectly. Then I try to add a new user to my project. TFS Express should allow until 5 users. I create a user on my machine and, using Visual Studio 2011, I add this user as Contributor in my project. Once done, I try to connect to the Web interface using http://:8080/tfs. I try to connect using the new user credentials but I get an error :
TF246017: Team Foundation Server could not connect to the database. Verify that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.

After some research, I finally found what is the problem.
Looking at the EventViewer, I found this message in the application logs :
Login failed for user . Reason: Failed to open the explicitly specified database ‘Tfs_Configuration’.

For some reason, my user tries to access the configuration database. Why ?
Because of a misconfiguration in IIS. ASP.Net Impersonation is enabled whereas it should not. I disable it and reload the page. It works now.

If you get this error, hope this post will help you.

May 20th, 2012 | Filed under TFS, Tools, Visual Studio

[EF] Code Fluent Configuration file

In my previous post, we saw how to configure Code First database generation with Code Fluent.

Here is what we’ve done in the previous post :

public class MyContext : DbContext
    {
        public DbSet<Person> Persons { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Task> Tasks { get; set; } 

        public MyContext():base("EFSample")
        {}

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<Task>().HasRequired(t => t.Project).WithMany(p => p.Tasks).HasForeignKey(t => t.ProjectId).WillCascadeOnDelete(false);
            modelBuilder.Entity<Task>().HasRequired(p => p.AssignedTo);
            modelBuilder.Entity<Person>().Property(d => d.BirthDate).HasColumnName("Birth");
            modelBuilder.Entity<Project>().Property(p => p.Name).HasMaxLength(255).IsRequired();
            modelBuilder.Entity<Project>().HasRequired(p => p.Manager);
        }
    }

As you can see, in real project, you can fastly get hundred of configuration lines here and it can become difficult to browse and to maintain. That’s why, Code First allows you to use configuration files to manage your configuration by entity type.
Read more…

[EF] Tips : Change database name created by Code First

If you are trying to use Code First, you should have seen the database name used by default is not always very useful and you surely want to rename it to use something easier.
To do that, you simply have to modified your Context class ti use the name you’ve choosen.

Here is a simple MyContext class :

public class MyContext : DbContext
{
	public DbSet<Person> Persons { get; set; }
	public DbSet<Project> Projects { get; set; }
	public DbSet<Task> Tasks { get; set; } 

	public MyContext()
	{}

	protected override void OnModelCreating(DbModelBuilder modelBuilder)
	{
		base.OnModelCreating(modelBuilder);
		modelBuilder.Entity<Task>().HasRequired(t => t.Project).WithMany(p => p.Tasks).HasForeignKey(t => t.ProjectId).WillCascadeOnDelete(false);
		modelBuilder.Entity<Task>().HasRequired(p => p.AssignedTo);
		modelBuilder.Entity<Person>().Property(d => d.BirthDate).HasColumnName("Birth");
		modelBuilder.Entity<Project>().Property(p => p.Name).HasMaxLength(255).IsRequired();
		modelBuilder.Entity<Project>().HasRequired(p => p.Manager);
	}
}

This code will generate a database named EFFirstSample.MyContext.

To change the database name I just do this little tweak : Read more…

Apr 16th, 2012 | Filed under EF, O/R Mapper, Tips/Tricks

[EF] Data Annotation and Code Fluent

Now that we have learnt how to create a database with Code First and how to declare foreign key relationship, let’s see what else can be configured.

In Code First, there is two ways for configuring database creation. The first one is using Data Annotation as we have seen on my second post about foreign key relationship, the second one is using the Fluent API.

Let’s see how it works.

Define MaxLength of a column using DataAnnotation

First, we will define our columns. If we take a look at the table Project, we can see that all our columns created from string type in our class are nvarchar(max).

NvarcharMax

Read more…

Apr 15th, 2012 | Filed under EF

Tips for Entity Framework Migrations

I just read this post this morning and found it very interesting. Some tips on how to work with EF Migration, what to check, what not to do …

Tips for Entity Framework Migrations

Maybe some of you can find it useful too.

[Managed Metadata] Error encountered in background cache check System.UnauthorizedAccessException

When you try to use Managed Metadata Service, if you get the following error on the Term Store : “The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator.”, check your ULS log.

If you find the following line with Taxonomy category an error code ca3r

Error encountered in background cache check System.UnauthorizedAccessException: The current user has insufficient permissions to perform this operation.

The issue should come from permissions. The account use to run the Managed Metadata service should miss some rights.

Here are some explanations on how to configure it with the right permissions :
Failed Background Check

Hope this helps.

Apr 4th, 2012 | Filed under Sharepoint, SP2010

SharePoint deployment : Optimization

As every SharePoint developer knows, deployment for SharePoint are sometimes really tricky and you have to be careful on how you manage it. IT Department wants to impact their users as less as possible and to do that, we have to configure our package to limit the down time of the production platform.
Here is a really interesting article about how to optimize your deployment regarding the availability of your platform :
Optimizing the process of deploying SharePoint Packages to minimize the impact on farm’s availability

I also find this article very interesting because it lists some tips really important on my opinion.

The tip really important to me is the use of the force attribute :

Never use the Force switch. Not only it makes SharePoint stop affected Application Pools but also it prevents you from seeing errors should there be any. The Force switch might be useful in some scenarios, like fixing broken deployments of SharePoint Packages, but in general you should try to avoid using it.

I think this is really important. If you use the force attribute you will think that everything went right, but it could be wrong. You just don’t see any errors. It doesn’t mean everything went ok. And sometimes, you will encountered some issues, you will spend lot’s of time to understand why, and will see that some features are not well deployed on all your Web Front End whereas there were no errors during deployments.

Windows 8 Consumer Preview installed

I just installed the Consumer Preview of Windows 8 and here are my first impression. Let’s start with the installation itself. It’s very very easy. I just put the installation files on a bootable USB key, then I boot on it and the installation began. You have to select a partition enter the windows key and that’s it. I came back later and I see the screen below, asking me to set up settings.

20120306-085116.jpg

Read more…

Mar 6th, 2012 | Filed under Actu Techno Microsoft
Tags:

EF Code First : Add foreign key relationship

In the first article, I show how to create a database with one table using Code First. You can read it here : EF Code First : Simple sample

Now, we want to add a new table to work with foreign key. Let’s add a new Project class like this :

public class Project
{
    public int ProjectId { get; set; }
    public string Name { get; set; }
    public int ManagerId { get; set; }
    public Person Manager { get; set; }
}

You can see the Manager property is of type Person and I add ManagerId property to be the key between the two tables.

Now add the DbSet of Project as you’ve done for Person :

public DbSet Projects { get; set; }

And run the application.
Read more…

Jan 23rd, 2012 | Filed under EF

Series of articles about EF Code First

As I begin to work a lot with Entity Framework Code First, I decide to write some articles to share some samples that could be useful for beginners.
Here is how I think to organize it :

1 – First sample : A very simple example on how to create a database with a table
2 – Add foreign key relationship : We will enhanced the application created on the first tutorial to add relationships.
3 – Data Annotation and Code Fluent
4 – Code Fluent configuration file
4 – Initialize database with data
5 – Table per Type and Table per Hierarchy

Tips : How to define your own Database name

I hope I’ll find enough time to write all of this.
Hopefully, I already write the first one !

Switch to our mobile site