File size

File size

File size

File size

File size

493.1 MB

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.

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 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.

@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.

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.

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>

@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:

Starting SQL Server Management Studio as an administrator (you should now be able to create and drop databases)

Expand the Root/Security/Logins node on the Object Explorer

If there is an entry for your Windows account right click and open properties, otherwise create a new login for your Windows user account.

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).

@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

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.

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 everytime4. 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.

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 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?

Remove this comment

Remove this thread

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.