Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Some help with Entity Framework

  • 29-05-2013 10: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,207 Mod ✭✭✭✭mewso


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


Advertisement