Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8192135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:06:21+00:00 2026-06-07T04:06:21+00:00

I have read a few articles about .Net Entity Framework that really didn’t make

  • 0

I have read a few articles about .Net Entity Framework that really didn’t make me want to try it out. But now I have started a small test.

I set up a MVC 3 site that will handle economy transactions for my family, just for fun. So I setup Membership provider and get the login functions working. Usually I use the Membership Guid in a column to identify each row to a specific user.

I setup this class in my project:

namespace mEconomy.Models
{
    public class Transaction
    {
        public Guid UserID { get; set; }
        public int TransactionID { get; set; }
        public DateTime Date { get; set; }
        public string Text { get; set; }
        public string Category { get; set; }
        public decimal Amount { get; set; }
    }


    public class TransactionDBContext : DbContext
    {

        public DbSet<Transaction> Transactions { get; set; }
    }
}

Works fine but I get the information on all users. If user A logs on and creates a few transaction then user B can create an account and see them. What is best practice here? How do I keep the user data separated?

I even tried setting the UserID as a private like this:

private Guid UserID = (Guid)Membership.GetUser().ProviderUserKey;

But that didn’t work at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:06:23+00:00Added an answer on June 7, 2026 at 4:06 am

    In your controller, use a linq query or the fluent api to retrieve only the desired entries:

    TransactionDBContext db = new TransactionDBContext();
    Guid userID = (Guid)Membership.GetUser().ProviderUserKey;
    

    Query builder:

    var transactions = db.Transactions.Where(t => t.UserId == userID);
    

    Or Linq:

    var transactions = from transaction in db.Transactions
                       where transaction.UserId == userID
                       select transaction;
    

    Edit:

    Do you want to always get the data filtered by userId without having to do where clauses in every place?

    Your best bet in this case is to create a method in the model to retrieve this data for you:

    // In your model code
    public IQueryable<Transaction> FromCurrentUser()
    {
        Guid userID = (Guid)Membership.GetUser().ProviderUserKey;
        return db.Transactions.Where(t => t.UserId == userID);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read few articles about table partioning but still I am bit confused
I have read a few articles on Internet about programming language choice in the
I read a few other articles about how people want to customize the colors
I have read few good articles about NHibernate localization but nothing seems to fit
I have read a few articles about how to programmatically interacting with Active Directory.
I have read a few articles about this, however, none of them tell me
I'm fairly new to DDD and have read a few articles about the concept
I have read a few articles online about optimizing javascript loading. A few key
Recently, I've read quite a few articles about Minitest. I really like the idea
I've read a few of the articles about the need / applicability / practicality

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.