Wednesday, January 30, 2019

TF400030 – [Solved] – The local data store is currently in use by another operation – TFS 2012




Introduction

In this very short post, we are going to briefly discuss a couple of common errors encountered in TFS 2012 when using local workspaces, running multiple instances of Visual Studio 2012, and having a large codebase.

Problem Description

If you are using TFS 2012 (including TFS 2012 Express) you may encounter one of the following errors:
  • TF400017 – The workspace properties table for the local workspace [name] could not be opened.
  • TF400030 – The local data store is currently in use by another operation. Please wait and then try your operation again. If this error persists, restart the application.
Pay particular attention to the highlighted word, local. These errors generally occur when you have a local workspace.
I was able to resolve this problem on my development machine by simply making sure that my workspace location was set to Server. Though this is the standard configuration we utilize internally, for some reason I had erroneously set my new workspace and forgotten to change its location. ðŸ˜¦
To ensure your workspace is a Server workspace, open your Team Explorer, select Source Control Explorer, then select your workspace and make sure that the location is set as shown below:
TFS 2012 - TF400030, TF400017
Once you set the workspace location to Server, the poor performance and unpredictability should disappear! Happy coding!












Reference:
https://blogs.msdn.microsoft.com/phkelley/2013/05/31/tf400030-the-local-data-store-is-currently-in-use-by-another-operation/

 https://johnlnelson.com/2014/09/08/tfs-2012-errors-tf400030-and-tf400017-concurrent-access-to-local-workspaces/

Sunday, January 20, 2019

The C# parameterless default constructor

i resolve this issue by fixing some constraint Keys attached with my Model

table was outdated / the constraints key got removed from Table and model was looking for reference to build the key


people may have different reason this issue causing DEPENDENCY INJECTION / Database

Tuesday, January 15, 2019

Convert Given Date to Julian Date

 var myDate = new DateTime(2019, 01, 22);
            var a = string.Format("{0:yyyy}{1:D3}", myDate, myDate.DayOfYear); //1994237
            var mod = (Convert.ToDecimal(a)%2);

Friday, January 11, 2019

EF support with SQL Server 2005

I am working on a asp.net project where my client is using SQL Server 2005. I want to design the data layer using Entity Framework 6, so, I just want to inquire if SQL Server 2005 is supported by Entity Framework 6. If not, which versions of Entity Framework are supported by this version of SQL Server.

Answer :
Yes, EF 6 supports SQL Server 2005 and later, SQL Server 2000 is NOT supported.

Reference :
https://stackoverflow.com/questions/25236427/ef-support-with-sql-server-2005

Sunday, January 6, 2019

Reflection to Get Property value

 var propertyName = DateTime.Now.AddDays(-1).ToString("dddd"); // Always 1 day behind             
                if (filterTimCard.Count > 0)
                {
                    var missingTimeCard =
                        filterTimCard.Sum(
                            x => Convert.ToDecimal(x.GetType().GetProperty(propertyName).GetValue(x, null)));
                    isMissingTimeCard = (missingTimeCard == 0);
                }

Wednesday, January 2, 2019

entity-framework-stored-procedure-table-value-parameter


UPDATE
i've added support for this on Nuget Package -https://github.com/Fodsuk/EntityFrameworkExtras#nuget (EF4,EF5,EF6)
check out the GitHub repository for code examples.
Slightly off question, but none the less useful for people trying to pass User Defined Tables into a store proc. After playing around with Nick's example and other Stackoverflow posts, i came up with this:
  class Program
{
    static void Main(string[] args)
    {
        var entities = new NewBusinessEntities();
 
        var dt = new DataTable();
        dt.Columns.Add("WarningCode");
        dt.Columns.Add("StatusID");
        dt.Columns.Add("DecisionID");
        dt.Columns.Add("Criticality");
 
        dt.Rows.Add("EO01", 9, 4, 0);
        dt.Rows.Add("EO00", 9, 4, 0);
        dt.Rows.Add("EO02", 9, 4, 0);
 
        var caseId = new SqlParameter("caseid", SqlDbType.Int);
        caseId.Value = 1;
 
        var userId = new SqlParameter("userid", SqlDbType.UniqueIdentifier);
        userId.Value = Guid.Parse("846454D9-DE72-4EF4-ABE2-16EC3710EA0F");
 
        var warnings = new SqlParameter("warnings", SqlDbType.Structured);
        warnings.Value= dt;
        warnings.TypeName = "dbo.udt_Warnings";
 
        entities.ExecuteStoreProcedure("usp_RaiseWarnings_rs", userId, warnings, caseId);
 
    }
}
 
public static class ObjectContextExt
{
    public static void ExecuteStoreProcedure(this ObjectContext context, string storeProcName, params object[] parameters)
    {
        string command = "EXEC " + storeProcName + " @caseid, @userid, @warnings";
 
        context.ExecuteStoreCommand(command, parameters);
    }
 
}
and the Store proc looks like the following...
ALTER PROCEDURE [dbo].[usp_RaiseWarnings_rs]
(
     @CaseID int 
    ,@UserID uniqueidentifier = '846454D9-DE72-4EF4-ABE2-16EC3710EA0F' --Admin
    ,@Warnings dbo.udt_Warnings READONLY
)
AS
and the User Defined Table looks like the following...
CREATE TYPE [dbo].[udt_Warnings] AS TABLE(
[WarningCode] [nvarchar](5) NULL,
[StatusID] [int] NULL,
[DecisionID] [int] NULL,
[Criticality] [int] NULL DEFAULT ((0))
)
Constraints i found include:
1.    The parameters you pass into ExecuteStoreCommand have to be in order with the parameters in your store proc
2.    You have to pass every column in to your User Defined Table, even if they are have defaults. So it seems i couldn't have a IDENTITY(1,1) NOT NULL column on my UDT
shareimprove this answer
https://www.gravatar.com/avatar/39b34c01992d4b7d1afe43bb4e8ec0e2?s=32&d=identicon&r=PG

1,6381525
  

This is exactly what we ended up doing. Sorry I didn't update the post with the solution. Thanks for taking time to do it! I have awarded you the correct answer. – Nick Olsen Mar 23 '12 at 14:36
  

Thanks, your question helped send me down the correct path :) – Mike Mar 23 '12 at 15:13
  

@Mike How this can be done in DataContext? – ssilas777 Nov 28 '12 at 9:15
  

I'm not sure ssilas777, I would assume the underlying data access components of the DataContext are similar to either a DbContext or ObjectContext. I'll look at supporting this with the NuGet package i've put up on Nuget :) – Mike Nov 28 '12 at 10:28
  

was it Db context or entity context? can someone help me? – Meghana Mathur A