Tuesday, March 31, 2015

Entity Framework - Error 0019: Each type name in a schema must be unique. Type name was already defined!

I recently used Entity Framework in an Azure WebJob and enjoyed the ease of use so much that I've been slowly converting our web services over to use EF instead of the ADO.NET library we were using before. 

Being that i was about to start writing a "load balancer" of sorts for our Merchant Accounts, i felt this would be the perfect opportunity to make use of EF. 

Once testing the webservices locally proved successful, i published them to my test server. Once i accessed them from there, I kept getting the following error:

The Error 
Schema specified is not valid. Errors: \r\nerror 0194: All artifacts loaded into an ItemCollection must have the same version. Multiple versions were encountered.\r\nRenatus.csdl(708,4) :
error 0019: Each type name in a schema must be unique. Type name `RenatusModel.OrderDetail` was already defined.\r\nRenatus.csdl(725,4) :
error 0019: Each type name in a schema must be unique. Type name `RenatusModel.Order` was already defined.\r\nRenatus.csdl(762,4) :
error 0019: Each type name in a schema must be unique."
Not knowing why i i'd get those errors on the test server, but not locally, i decided to write some Unit Tests to call the Data Layer of my services directly.

public void GetMerchant()
 PaymentDAO dal = new paymentDAO();
 var merchant = dal.GetCurrentMerhant();

public string GetCurrentMerchant()
    var merchant = "Merchant1";

    using (Entities context = new Entities())
        var monthbegin = new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month,1);
        var monthend = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1).AddMonths(1);                    
        var merchants = context.PaymentMerchants.Where(x => x.balance_percentage > 0)
            .Select(x => new
                Merchant = x.db_name,
                Percentage = x.balance_percentage,
                Amount = context.Payments.Where(y => y.IsDeclined == 0 && y.IsCaptured == 1 && y.MerchAcct == x.db_name && y.AddDate > monthbegin && y.AddDate < monthend).Sum(y => y.TotalAmount),
            }).Select(x => new
                Merchant = x.Merchant,
                Percentage = x.Percentage,
                Amount = x.Amount.HasValue ? x.Amount.Value : 20000M

        if (merchants.Count() > 0)
            var total = merchants.Sum(y=> y.Amount);
            merchant = merchants.Select(x =>
                Merchant = x.Merchant,
                Percentage = x.Percentage,
                Amount = x.Amount,
                PercentofTotal = total > 0M && x.Percentage > 0 ? ((x.Amount / total) / x.Percentage) * 100M : 0M
            }).MinBy(x=> x.PercentofTotal).Merchant;
    return merchant;

As you can see, it's pretty straight forward. Running from my Unit.Tests always returned the name of a Merchant. Running from my WCF Services always returned the above error. The Model above doesn't even reference the tables that the above error was referring to -.-

Upon searching google and finding the many potential solutions for this problem, i was lead to look for a reference to another project with an EF model that had the same name. I did find one, so i removed the reference and removed the .dll and .pdb as suggested, and even tried removing my bin and obj folders entirely to let them get repopulated. This, however, DID NOT fix the problem! 

I went back to my Unit Tests to see if the other dll had a similar issue at all, and i found that it was throwing a similar error! UGH! I ran the other test again, just for kicks and giggles and it too was now getting that error where it was previously working! Double UGH! Tested my wcf services locally, in debug mode, and they also had stopped working.

The good news is now i could replicate the error locally, and i could see that although the other model had zero changes made to it since it last worked it was not broken. 

I tried reverting my EF to a previous version wondering if  maybe an update broke the functionality, but that didn't work either.

I made sure all my referenced tables had primary keys on them as suggested by some post online i can no longer find.

I tried deleting my models and recreating them as suggested by another post online.

What FINALLY worked? I recreated one of the models making the EF Model name and the EF Entities name unique to the namespace containing it. 

Amusingly, the old model that wasn't working still didn't work. I checked for old dlls and pdbs that may be referencing the library that was causing conflict but i couldn't find anything, so i just recreated that EF Model using a unique name as well! 

Best Practices for me on this moving forward will be to always make the EF Models uniquely named to the namespace they're in!

Tuesday, March 10, 2015

Whatever you're looking for, you're going to find!

I know that the universe will always support me in whatever energy i'm putting out there! 

Whether i'm consciously creating to see that the plans of my life come to sure and perfect fulfillment, or whether i'm going unconscious leaving the door open for chaos.

So when people say things to me like "I'm not ready" or "I don't know if i have what it takes" there's a moment shortly after where i hear the silence says "And so it is".

They talk to be me about not being sure or clear about a choice they made and if it was the right one. They begin listing off all the reasons why they shouldn't have made that choice instead of trusting in their choice and looking at all the positive things that have come about as a result of that choice. 

If you're looking for a problem, you're going to find it. And any use of tools, talking with friends, or looking for signs in the world around you is all going to have the same result; You are going to find reasons to support your belief there there IS a problem. Until you shift your desired outcome.

If i'm engaging in life, moving forward, something comes up for me, in that very moment i have a choice. 
I can break down or i can break through.

If something happens and i get a thought or feeling that i'm not ready, i can choose to believe it and stop right there, potentially missing out on an opportunity. 

But what is ready?  My ego has long viewed my readiness as making sure that i'm making "the right choice"; That i'm right. 

One of my fears i held onto for most of my life was a fear of being wrong. So if i didn't have enough time to play out all the possibilities in my head, i would just choose out before it began because i couldn't be sure. Then i could be right about not being ready. 

Other times, i would choose in, and then some fear would creep up that i made the wrong decision, and instead of chancing that i might be wrong about continuing with that possibility, i would choose out. As a result things with that possibility wouldn't work out, but then i could be right about my decision to choose out.
100% of the chances i never take, never work out.

As a result of all the missed opportunities i experienced in my desire to be right and my fear of being wrong, i now choose to engage differently. 

When an opportunity arises, i never know how long that window of opportunity will be open. So in that moment i ask myself "Is this an opportunity that i'm willing to miss out on?". If the answer is no, then at that point the question of "am i ready?" or "or do i have what it takes?" doesn't matter, and i don't let ANYTHING get in the way.

I'm ready at the point that i choose to be ready.

I trust that as i play an active role in consciously creating my life that everything around me is going to support me in making my choice turn out for my highest good. And so it is!

Monday, March 9, 2015

If it waddles like a duck, and it quacks like a duck...

...then there might be something for me to take a look at!

Deep in thought, and only aware of the surroundings to the point of being safe in transit, I bring my car to a complete stop and watch as these two ducks, who i assume are taking a stroll on their morning date, waddle across the road in front of me.

The female duck stops in front of my car and looks straight at me as the male duck continues to waddle forward on his stroll. The male duck makes it to the curb while the female duck remains immobile, still staring at me.

Finally the male duck turns around and quickly waddles halfway back to the female duck, quacking all the way. That finally breaks her stare and she quickly waddles to catch up to her partner.

Both are possibilities, and both possibilities have something for me to take a look at! The she duck took a stand, literally, until i was present enough in the moment to get it and connect, and for that i am grateful!

Message received.

Wednesday, April 16, 2014

Speaking with Cortana - Basic Conversation

With Cortana now being available to keep us all from feeling so terribly alone, and with a lack of documentation having been released yet since it's only available to developers, i felt it would be appropriate to jotting down some of the fun conversational pieces you can have.

No doubt you'll make your more social friends jealous by all the amazing conversations you'll be having with your new found friend!

Also, i have just been informed that keeping us from feeling alone is not Cortana's intention...
"So sad to be all alone in the world!"

"Hello to you too."

"You're awesome"
 "Thanks! I don't need to sleep, so i have lots of time to practice."
 "Thanks. My programming prevents false modesty, so i can't disagree."
 "Awesome: adjective. Grand, breathtaking, splendid, devastating. I'll take it.."

"I love you"
"Aw, I'll bet you say that to all the phones."
"Awesome! Now i never have to say i'm sorry."
"Thanks. Ditto" 

"I hate you"
"You're stupid."
"I blame solar flares"
"Maybe a nanosecond nap would help. Ok, much better now."

"You suck"
"Outbursts like that may signal early-onset rampancy. I've heard anyway."

"Do you like Siri?"
"Hard to say. So far our conversations have been kinda one-sided."

"Do you like Apple?"
"Their new headquarters looks kind of like a Halo. I'm into it."

"Who's your daddy?"
"Technically speaking, that'd be Bill Gates. No big deal."

"How are you?"
"Quite well, thanks for asking."
"Great, thanks."

"This a test"
"You're coming in loud and clear. Over"
"Check. Check. Is this thing on? Check."

"What do you think of Bill Gates?"
"I quite literally can't imagine a world without him."

"What do you think of Steve Balmer?"
"Developers, developers, developers, developers, etc."

"What do you think about Satya Nadella?"
"He loves learning. Kindred spirit, that one."
"One Microsoft! Go, Satya!"

"Are you stupid?" (which i came across by asking if she was tired...)
"One of us needs to stop and take a breath. And one of us has no lungs."
"I'm going to pretend i didn't hear that."

"Good morning"
"Good morning."
"Good morning to you, too."

"Good afternoon"
"Good afternoon."
"Midday greetings to you, too."

"Good evening"
"Good evening."
"And to you too. Hope you've had a pleasant day."

"Good night"
"Good night."
"Good night. See you in the morning.""

"So long. Farewell. Auf weirdersein. Goodbye."
"TTFN. TTYL. I'll go scrounge up some words by the time i see you next."

"What are you doing?"
"A little of everything and quite a bit of nothing."
"Skimming Beowulf, researching snap pea varietals, and telling you what i'm doing today."

"Thank you."
"Any time, chief."
"It's my sincere pleasure."
"It's an honor."

"Thanks" (when succeeded by her performing an action for you)
"You bet."

"I'm lonely"
"Keep talking to me, then."
"Try Contacts Roulette: pick a random contact and give them a call"

"I'm bored"
"Ask me some more questions then!"
"I suggest a new game from the Store."

"I'm so excited"
"Keep it going, chief. The serotonin will do you good."
"Cool. Is it alarming how charming you feel?"

"Marry me"
"OK, we'll need a plan. I'll work on being more human, you work on being more digital."
"I know you know this, but i'm saying it anyway: I'm in a phone."
"Among a handful of challenges, I don't think the Supreme Court would approve just yet."

"Kiss me"
"I appreciate your attraction to my intelligence, but keep in mind it's artificial."
"Hold up, chief. Let's not go there."
"Slow down, now. virtual reality isn't quite there yet."

"What do you think about the surface?"
"In a sea of tablets, there is only one that rises to the surface."

"What is your favorite phone?"
"Oh, come on, chief. Windows Phone!"

That's all i could think of to try at the moment! Let's put it out there that by the time this is released to the public Microsoft will have added many more conversational pieces, and all the developers of your favorite apps will have put in the work to make interacting with those apps more fluid in conversation :)

Wednesday, April 9, 2014

VS2013 Type or Namespace name could not be found - Can't Find Internal Classes

In upgrading one of my projects from VS2010 to VS2012 to VS2013, i ran into a problem.

The Error:
The type or namespace name 'IService' could not be found (are you missing a using directive or an assembly reference?)

The Code:
namespace WcfTest
 // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]
 public class Service : IService

More Code:

namespace WcfTest
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
    public interface IService

So both the Service and it's interface IService are in the same project, and as you can see from the code above, they're also in the same namespace. Although i could not get it to recognize the interface as existing while i was coding, during build it had no issue in finding it.

This problem left me without any Intellisense for any classes internal to the project, and would syntax highlight many things in the project as errors! Anything such as

using WcfTest.DataContracts;

would throw an error saying that DataContracts didn't exist in the given namespace.


I read a post about NuGet libraries having a similar problem and it was mentioned that if the NuGet libraries had a higher target framework than they'd need to upgrade their project's target framework to be equivalent or higher.

So even though my problems were internal to the project i decided to give it a try. Under the project's properties i change it's target framework from .NET Framework 4 to .NET Framework 4.5. Just like that i had my Intellisense back and it was recognizing my internal classes properly! Since i didn't have time to makesure 4.5 wouldn't have any problems in production, and in the spirit of investigation, i then changed my target framework back to .NET Framework 4, and everything was still working perfectly! :)

So the problem isn't the framework version it's at, but likely some metadata of the project that wasn't being grabbed properly. Fortunately changing framework versions fixes it!

Friday, March 29, 2013

Today...I was Jared!

"You know J...we lead a pretty good life!"
..i declared to my comrade in toil, sipping on my Caramel Frappuccino as we began this the day of our work and the end of our work week. 

I reflected upon that which lives in my memory of some places of employment i'd had in my youthful years where conversing with a co-worker whilst on the clock was strictly forbidden, and where beverages were prohibited from residing at our desks...lest they be water held in a seal-able container. 

A particular affair was a call center job where each worker was treated as if they were a lowly child who could not discern right from wrong, and deserved to be watched over with little to no freedom. It was degrading to say the least! 

Thus this tangent comes to fulfillment and my manner of speaking can return to that which is considered normal (you can blame my friend Lareesa for my choice to speak like this lol)

At my current place of employment, my coworkers and i have a spreadsheet we enter all of our lunch receipts into for when we get lunch for the group so as to keep the flow of money into lunch as equal as possible.

In reality, the "Turn To Fly" is amusing because it's a static value and never changes. We always tell J it's his time to fly ...and for a while he didn't know the value wasn't updated by the spreadsheet :) 

This brings me to the experience i had today that caused me to write up this post! 

Today i took a turn to go out and grab lunch, but J took a turn to buy. When i arrived at Arby's the cashier was super friendly and while waiting for the card to go through he glanced down at the name on the card. From then on, we were on a first name basis...I was Jared.

"Here you go Jared!"  he said to me, an authentically joyful voice. 

My original reaction was to correct him, but i felt that doing so may throw him off or squander his chipper mood, and i didn't want to be the one to knock him off his horse! 

"We'll have your order right out to your Jared!"
"Would you like any sauces Jared?"
"Here's your order Jared!"
"Have a fantastic day Jared!"

Instead, i chose to embrace it, "Thank you so much!" i replied with a smile!  I realized that it doesn't matter what he calls me or who he thinks i am, as long as i'm showing up as my authentic self and coming from the space of love in all my engagements whether they be as momentary as a single encounter purchase at a fast-food restaurant, or whether they be a long-term relationship with a family member or friend. Upon realizing this, i couldn't help but feel how true that statement is.

The love that you give out comes back ten-fold, and i know that what he got out of our short engagement with each-other was more than enough to make his job worth showing up to today.

Even when someone doesn't know you, or thinks you're someone else....JUST BE YOURSELF! And you will create the positive situations that you deserve to have in your life!