Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Visual Studio Toolbox: Entity Framework Part 1

Download

Right click “Save as…”

In this episode, Robert is joined by Rowan Miller and Diego Vega of the Entity Framework team. They discuss and demo code first, database first, and model first—the three primary Entity Framework workflows—and give some tips on when to use each. They also clarify the update strategy for the Entity Framework and how to obtain newer bits.

Demos:

  • Code First, starting at about 26:00
  • Model First, starting at about 29:20
  • Database First, starting at about 44:50
  • Code First with an existing database, starting at about 47:45

Tags:

Follow the Discussion

  • felix9felix9 the cat that walked by itself

    I can't install EF 4.2 NuGet because no RiaServices.EF support it, awww....

    And, Enum support can't be supported on .NET 4.0, awww.....

  • @felix9:What do you mean by no RiaServices? What happens when you try and install EF 4.2?

  • Everyone. Let me know if this is too long. Would you prefer fewer demos? Would you prefer this was broken out into multiple episodes? If so, should they be posted one a week or more frequently? Or is this length fine from time to time?

  • I've been meaning to jump into EF land for a while now but just haven't had the chance to read up on it, so thanks! The video length was perfect, just enough to watch over the lunch break.

  • i also watched this over my lunch break. I am fine with the video length and I think covering these types of topics/products is very important for successful adoption 

  • I've enjoyed all of your talks.  In general, short and to the point is good, but for a topic like EF, please don't shorten or limit the guest.  I feel like when you let the developers speak, they are giving out additional goodies that are hard to come by.

  • Is there a way to specify relationships with code first?

    i.e.  One class that maps to a table with a relationship to another table?

     

  • felix9felix9 the cat that walked by itself

    , rogreen wrote

    @felix9:What do you mean by no RiaServices? What happens when you try and install EF 4.2?

    I meant 'no RiaServices.EntityFramework that support it'.

    RiaServices.EntityFramework has a dependency on 'EntityFramework (≥ 4.1.10331.0 && < 4.2', so I can't install 'EntityFramework 4.2.0.0'.

  • David AndersonDeadX07 Microsoft Partner (MSP)

    @rogreen:I actually prefer longer episodes that go really in depth. I listen to these while I work and the longer episodes allow me to listen without having to load a new one in the player every few minutes. As far as going in depth I am an advocate of learning through experience and from others rather than just white papers. Shared knowledge is often more easily remembered and the experience that comes with it is something you can't get from a document.

  • Vesuviusvesuvius Count Orlock

    I was an early adopter and soon because averse to this ORM. I will have a look at it again, but hope you maintain the mantra of keeping it as easy to use and as logical as possible.

    Doing the same thing with the Linq to SQL ORM was much easier than EF, so I hope things have changed for the better.

  • Rowan MillerRowan Miller

    @WizardX - You can see an example of relationships in this walkthrough; http://blogs.msdn.com/b/adonet/archive/2011/09/28/ef-4-2-code-first-walkthrough.aspx

  • Entity Framework with LINQ is THE BALLS! 

  • Lee ColinsLee Colins

    I see that with ASP.NET MVC + Code First you can easily set up attribute-based model validation on both client and server.

    But what about ASP.NET MVC + Model First?

  • Lee ColinsLee Colins

    I mean will they be a little less painful, for example, you can set "required" flag in the model designer. I don't see why you shouldn't be able to set other validations in the form of DataAnnotations right there in the visual designer, instead of keep jumping from the designer to code and back.

  • morteza hosseinimorteza hosseini

    hi everyone<br>i have a big problem with entityframework<br>when i make my model and databases and everything needs to be ready on my code when i want save changes with context.savechanges&#40;&#41; it throws an exception &#40;&#34;inner exception&#34;&#41; and i dont know what to do please help.&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33; <br>

  • RogerRoger

    I think the length of the episode depends on the topic,
    the most important thing for me is to get something from the
    episode.
    so for sth like EF i think its acceptable to be 50m.

  • dreamdream

    都是英语~~~~汗~~

  • Length is perfect. Shorter videos are ok as well but in my opinion, 60 minutes should be the top limit.

  • -- Would you prefer fewer demos?

    No man! More! Keep it up like that and even longer would be better. Also, as Rowan Miller mentioned let's spend two hours on configurration Smiley

    -- Would you prefer this was broken out into multiple episodes?

    1 hour was nice.

    -- If so, should they be posted one a week or more frequently? Or is this length fine from time to time?

    This length is nice but once a week or more frequently. I cannot say no to anything that contains DbContext :d

  • @Lee Colins

    Partial classes are you friends if you are using code generation. Do not set attributes on generated code because they will be lost when you update the schema and generate the code again.


  • Hi.

    perfect and remarkable.

    but here is a problem with the accents,Its going to be a big problem for me and my frinds to understand what these guys say , Is it possible to prepare a subtitle or put context of them ??

    it will be very helpful for us.

    tnx for all.

  • When I run the console app on the CF example it throws this exception:

    CREATE DATABASE permission denied in database 'master'.

    Any ideas as to why. I must say that I using SQL 2008 and My login is registered in the Security settings.

    What I'm missing here for this to work???

    Thanks in advance for your help. 


     P.S.: Glory to JESUS for ever Rowan!!!

  • @Rowan Miller :

    As Oracle now officially supports EF 4.0, I am moving toward to using EF for new projects, the presentation is very helpful introduction.

     

    Where could I download the slides? Also, what zoom in tool you are using? I like how you are able to create a arrow after you zoom.

     

    Thanks for the nice presentation!

  • @Lee Colins: Tugberk is right. DbContext and MVC both work with the "buddy class" pattern explained here: http://msdn.microsoft.com/en-us/library/ee256141.aspx (look for the MetadataType attribute in the article). This is your best option to specify data annotations for validtion if you are using code generation to get your entities. I would also add that DbContext validation checks string lenght and nullability constrainst specified in your EDM model without the need to have data annotations in your C# or VB classes.

  • @Edson_Ferreira: I have seen this error come up when your login credentials actually lack the necessary permissions in SQL Server.

    This is often the consequence of installing SQL Express using a different user account from the one you are trying to use it. It has happened to me when I take a virtual machine image prepared by another person.

    One way to confirm this is your case would be to open SQL Server Management Studio logging in with your regular use account and attempt to create a database manually, e.g.:

    USE master;
    CREATE DATABASE delete_me_next;

    If you get the same error message you are getting is code first, there is your problem.

    You should be able to work around this by running Visual Studio and your Code First app as an administrator every time, but this is not very safe so I would recommend that you rather grant the required permissions to your login use in SQL Server permanently.

    There might be an easier way but you should be able to do the later this way:

    1. Starting SQL Server Management Studio as an administrator (you should now be able to create and drop databases)
    2. Expand the Root/Security/Logins node on the Object Explorer
    3. If there is an entry for your Windows account right click and open properties, otherwise create a new login for your Windows user account.
    4. Under Server Roles make sure there is a checkmark on a server role that has permissions to create databases, e.g. dbcreator or sysadmin.

    If this is not the reason CREATE DATABASE is failing, another possibility is that the local account under which the SQL Server service is running doesn't have the necessary file system permissions to create files in the default location for new databases (i.e. under the ...\MSSQL\DATA directory).

    Hope this helps.

  • @morteza: I am guessing that the exception message you tried to paste got mangled. Could you try again pasting it in notepad first before you put it here?

  • @felix9:I have forwarded your post to the RIA Services team.

  • @DiegoV:Thanks Diego I'll try that - your guys rock!!! great presentation and wait to have a look at Part 2.

    Just as an update I actually overcame that issue by specifying a connection string to an .sdf file instead. But I need to try your solution as I do want to replicate exacly what you guys are doing in these tutorials

    Thanks once again Diego Big Smile

    Edson

  • , rogreen wrote

    Everyone. Let me know if this is too long. Would you prefer fewer demos? Would you prefer this was broken out into multiple episodes? If so, should they be posted one a week or more frequently? Or is this length fine from time to time?

     

    @rogreen: I like having single long videos.  I really dislike shorter videos spaced out over time.  I often want to absorb and apply as much as I can when I'm looking at something new.  The number of demos was fine, it showed a cross section of major features in an approachable way. I found the brief coverage of the generated code differences to be very useful. The only thing I can think of that would add a lot of convenience would be to list the times of the demos/subject coverage to the description so we can skip to what we're interested in.  I was most interested in the two demos on CF but had to watch the other two in the middle.  I had no idea that the last demo was even going to happen.  A table of contents with times would resolve that wonder, especially in longer videos.

    Thanks for the great content.

  • @jsmxwll:Adding times is a good idea. Thanks.

  • Nyc one.. loved it::

  • @rogreen:This was not long. The length is sufficient and it is packed with a lot of info. Keep up the good work Robert.

  • Abhishek luvAbhishekLuv Abhishek

    @rogreen: length is fine Tongue Out

  • Subu MysoreSubu Mysore

    THANK YOU for such an excellent job to make developer's life that much easier.
    Here are my concerns.
    1. EF as the alternative cannot yet be justified, simply because, it cannot target multiple databases.
    2. Code first might not be the best approach yet, especially if you have to verify the database schema, after the EF creates the schema.
    3. We cannot be expected to drop DB objects every time a change in code occurs. Even in a Dev environment, there will be test data and we cannot be blowing away the database everytime
    4. Most importantly, please, when you suggest an alternative approach, please ensure that all the feature/capabilities of traditional appoaches are met.
    Again, sincere appreciation to all of your efforts.

  • @Subu Mysore:EF supports dataabases that have an entity provider that works well with it. By the way, Oracle recently released a provider that supports EF 4.

    As for #3, you should watch the Part 2 episode which will be live tomorrow. Code First Mirgations are coming in EF 4.3 and sync your code changes with the database.

    Robert

  • SandySandy

    Hi,

    I created a new console project & trying to implement codefirst development as shown in the project. When I execute the project it's throwing an error.
    Error Message: "The type 'CodeFirst.Program+Blog' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject."

    I am not sure what to do next.

  • SandySandy

    I figured the out issue. Thanks

  • This is great presentation.

    We can use the latest Microsoft SQL Server Data Tools  in order to handle SQL server database structure from inside the VS2010.

    Thanks.

     

  • SrikanthSrikanth

    Video was good. Thanks for it.

    My only concern was with NuGet which needs a internet connection.

  • ChenChen

    Hi,

    I wanted to start working on a new project using the EF, however I'm a bit concerned about the comment:
    Every time I change something on the objects structure/properties, the EF needs to rebuild my database. Why? What about the develpment data?


    Best regards,
    Chen

  • RafaelRafael

    So...it looks great. The question is.. does EF 4.3 work with Oracle 10g + or just MSQL Server ?

  • @Rafael: Entity Framework works with any database if the database maker supplies a provider. Oracle has a provider that supports Entity Framework 4.1 and 4.2, although it does not support Code First.

    Robert

  • @Chen: If you use Code First without Migrations, you will see this because EF changes the database to match the class structure you create. But if you use Database First that doesn't happen. EF creates the class structure to match the database. Check out Code First Migrations in the Part 2 video and at http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx.

    Let me know if you have additional concerns or questions.

    Robert

  • What is difference between POCO and Code-First approach? Thanks Rajesh
  • YasserYasser

    Hi ! This would be more useful if the video would have been divided into 8-10 chapters each with a heading of what actually the video discusses or explains. Just a suggestion,

    Regards
    Yasser

  • Ankur GoelAnkur Goel

    This video is quite useful for beginners. It's really helpful.

  • Video length is good. Helpful, thanks.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.