title: How to create a "non-dynamic" Guid as value for a database entry?
body: <p>I'll try to explain what I'd like to obtain:<br>
  I'm trying to create a Guid value as an attribute of my database entry.<br>
  I've already checked other questions and answers to resolve my issue and this is the Model I got so far:  </p>
  
  <pre><code>public class MyModel
  {
      private Guid myGuid = Guid.NewGuid();
      public Guid MyGuid
      {
          get { return myGuid; }
          set { myGuid = value; }
      }
  }
  </code></pre>
  
  <p>But the issue isn't in this code. Because in this way, the Guid value is automatically generated and I'm able to verify the Guid in my Views.<br>
  But every time I edit an entry in my DB the Guid is kinda refreshing itself and change. That's why I called it "dynamic" Guid.<br>
  I guess because the attribute <strong>MyGuid</strong> recall every time the private part of the data model (<strong>= Guid.NewGuid();</strong>).<br>
  So how could I create a random Guid and later set it as value of MyGuid?</p>
  
  <p><em><strong>EDIT-1</em></strong>  </p>
  
  <p>I created a method in my Model in order to create a more precise Guid generation. Now my model looks like this:  </p>
  
  <pre><code>public class MyModel
  {
      public string myGuid = Convert.ToString(new Guid());
  
      public string MyMethod(string myValue)
      {
          var empty = Convert.ToString(new Guid());
          if (myValue == null || myValue == empty)
          {
              var newGuid = Guid.NewGuid();
              string stringGuid = Convert.ToString(newGuid);
              return stringGuid;
          }
          else { return myValue;}
      }
  
      public Guid MyGuid
      {
          get { return myGuid; }
          set { myGuid = MyMethod(value); }
      }
  }
  </code></pre>
  
  <p>This method worked only once, during a test on another project, and then, when I tried to import this method, it broke and stopped working.<br>
  Using this method, when I create an entry in my database, it should generate a Guid.NewGuid() every time my Guid editor field is empty or have a zero Guid, isn't it?<br>
  So, why this code is working on a side project and it's not working on another one?<br>
  What am I missing?</p>