Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Some help with Entity Framework

  • 29-05-2013 9:02am
    #1
    Registered Users, Registered Users 2 Posts: 52 ✭✭


    Good morning,
    I'm very new to Entity framework and could do with some help.

    I have the following code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data.Entity;

    namespace EntityFramework.EntityFramework
    {
    public class LodeTable
    {
    }
    public class Blog
    {
    public int Blog { get; set; }
    public String Name { get; set; }
    public virtual List<HttpPostedFile> Posts { get; set; }
    }
    public class Post
    {
    public int PostID { get; set; }
    public String Title { get; set; }
    public String Content { get; set; }
    public Int BlogID { get; set; }
    public virtual Blog Blog { get; set; }
    }
    public class BloggingContext : DbContext
    {
    public DbSet <Blog> Blogs { get; Set; }
    public DbSet <Post> Posts { get; Set; }
    }
    }

    When I try to compile I get the error:
    Error 1 A get or set accessor expected LodeTable.cs 28 42 EntityFramework

    I've read a few tutorials but I cant see where I'm going wrong.

    Can anyone spare a few minutes to point me in the right direction?

    Using Visual studio 2012, .net 4.5 and Entity Framework 5.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 403 ✭✭counterpointaud


    Code compiles for me, once I changed 'Int' to 'int' , 'Set' to 'set' and changed 'public int Blog' to 'public int BlogId' (using new MVC4 empty web application project and EF5).


  • Registered Users, Registered Users 2 Posts: 52 ✭✭digitaldarragh


    That's absolutely brilliant.
    It was a stupid thing for me to miss.
    I wrote it a second time after writing the post this morning and I still managed to write a capital S for set at the end of the file.


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    I suspect "List<HttpPostedFile>" should read "List<Post>" too. Intellisense can be too quick sometimes.


Advertisement