title: Still getting Ecto.Association.NotLoaded after using Repo.preload
body: <p>I'm still getting Ecto.Association.NotLoaded even after preloading with Repo.preload(). I have a store schema that has_many :books, when I try to add a create store, I get this error:</p>
  
  <pre><code>%App.Stores.Store{__meta__: #Ecto.Schema.Metadata&lt;:loaded, "stores"&gt;, 
  name: "mystore", description: "book store", id: 13, inserted_at: 
  N[2018-10-10 16:52:24.155385], name: "mystore", books: 
  #Ecto.Association.NotLoaded&lt;association :books is not loaded&gt;, 
  updated_at: ~N[2018-10-10 16:52:24.155397]}
  </code></pre>
  
  <p>I have researched and found out that my :books association was not loaded, so I added this to my store context</p>
  
  <pre><code>def list_stores do
      Repo.all(Store)
      Repo.preload(:books)
  end
  </code></pre>
  
  <p>But still getting the same error.</p>
  
  <p>Please this is my schema</p>
  
  <pre><code> schema "stores" do
      field :description, :string
      field :name, :string
      has_many :books, Myapp.Books.Book
      field :owner, :string
  
   timestamps()
  end
  
   @doc false
   def changeset(store, attrs) do
      market
      |&gt; cast(attrs, [:name, :description, :owner])
      |&gt; validate_required([:name, :owner ])
  end
  </code></pre>
  
  <p>and </p>
  
  <pre><code> schema "books" do
      field :title, :string
      field :author, :string
      belongs_to :store_id, Myapp.Stores.Store
  
      timestamps()
    end
  
    @doc false
    def changeset(pair, attrs) do
      pair
      |&gt; cast(attrs, [:name, :description])
      |&gt; validate_required([:name, :description])
    end
  </code></pre>
  
  <p>and lastly my migration file</p>
  
  <pre><code>def change do
      create table(:books) do
        add :title, :string
        add :name, :string
        add :store_id, references(:stores, on_delete: :nothing)
  
        timestamps()
      end
  
      create index(:books, [:store_id])
    end
  end
  </code></pre>
  
  <p>Please, I don't understand, I'm new to elixir and have researched for other solutions since the preload is not working. It seems I messed up somewhere in my code, please where did I get it wrong? </p>
  
  <p>Thanks.</p>