i18n in asp.net using resources and entity framework - asp.net

I've been trying to store my strings in a database using resource files to fetch them. I've been following the guide from http://afana.me/post/aspnet-mvc-internationalization-store-strings-in-database-or-xml.aspx
The example works fine enough when i use his sql code based on ADO.net to fetch the strings from the database.
But i want to use Entity Framework to fetch the strings from the database, because my translation table is quite different. Could anyone show me an example of how to use Entity Framework in the resource project(assembly?), because i can't seem to get it to work. I cant import any of my models or contexts from my main project with "using", and it tells me i have duplicate models when i copy them to the resources project/assembly

Related

Re-use schemas within BizTalk solution using XSD Import (Importing types from another schema/namespace)?

I have crated schema project and use consume adapter service wizard to generate schema for SQL DB table to perform insert operation. (Filename Prefix : Batch_)
How to overcome with issue when I tried to reuse schemas and build new schemas (Common) out of existing types ?
So, when I check Request schema node and try to find data structure type I got nothing ?
It's not totally clear what you're trying to do. But...it probably doesn't matter.
While technically possible, you really shouldn't be trying to craft your own schemas, just use what the Wizard emits directly.
With one exception, the common types, those you can consolidate because the xsd is the same for all generated Schemas.
More here: BizTalk Server: Reducing and Consolidating WCF Serialization Schema Types

EF automatically update EDMX file

I was wondering if there is a way to update the EDMX file in programmaticaly (in c#). I need to switch to database from different versions which requires the model to change frequently.
Thanks in advance!
Entity Framework DataBase first creates an XML (EDMX) file and a set of classes linked to it, this way you access to the model generated (tables, views, stored procedures) in your code.
So when you say update the model in run time, you basically want to re-generate a set of classes in run time and I don't think that is possible.
If you want to access to different versions of a DataBase (maybe different customers) you can do it at a db level creating Stored Procedures and using them in code. Or generating one model per DB.

Entity Framework Reverse POCO

We have an existing Db with about 100 odd tables - These were created the old way - use sql queries to generate the Db and use the SQL reader/writer to access and update the DB's.( ADO.net). A developer prior to me added few new tables to this using the EntityFramework (EDMX) approach. They just named the tables generated newly "DBEntities" and used this as a data source for the new pages that were then written in ASP. net webforms(apsx).
I am now tasked with developing some of the newer pages on this existing webforms app to be built in Angular 2.0. I started off with consolidating the one DB that this app reads ( which were referencing both the EDMX file and ado.net - having two config file entries - add name ="DbConn" connection string "".. and add name="DBEntities" the edmx conn string".) I removed the edmx files , used the reverse poco generator and created first class POCO's and generated my tt file. Updated my web config to include only one connection string "DBConn". Tested the app - all the old web form pages were working well. Only those aspx pages(controls that use DataBind..) that were referencing the EDMX files gave me this error - The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
I have tried everything(regenrated POCO's.. checked all the table names against the aspx data sources everything looks good..) and nothing seems to work. Using EF6. - Any help is appreciated..
Thanks much.

ASP.NET MVC with User Defined Type

I try to create simple ASP.NET MVC5 app where I can access to my table. The table has user defined type inside.
I followed this tutorial:
http://www.asp.net/mvc/overview/older-versions-1/movie-database/create-a-movie-database-application-in-15-minutes-with-asp-net-mvc-cs
Unfortunately, when I use Entity Data Model and try to generate model from database, my UDT field is ignored. I've got an warning:
The data type 'Pesel' is currently not supported for the target Entity Framework version; the column 'x' in the table 'y' was excluded.
So my question is, how can I add my UDT to entity model?
I've tried to manually create a model and then use Entity Framework to generate controller and views. Again, UDT fields are ignored.
Thanks for help!
I've personally not used User Defined Types, but I'm sure you have a good reason for it. After reading your question, I decided to learn more about UDT's and try and find an answer for you. From what I've read, you should be able to do it as long as you reference the assembly for the definition in your project. Otherwise, your project will have no idea what the data type is or how to use it.
Here is some text from the "Professional C# 4 and .Net 4" book:
Using UDTs from Client - side Code
The assembly of the UDT must be referenced to use the UDT from client
- side code. Then it can be used like any other type on the client.
Because the assembly containing the UDTs is used both from the client
and from the SQL Server, it is a good idea to put UDTs in a separate
assembly from the other SQL Server extensions such as stored
procedures and functions.

Validate EF Code first model against existing database

Is there a way to check that a DbContext matches the database when the database was not created by EF code first?
I am looking for similar functionality to Database.CompatibleWithModel but there is not metadata.
There is currently no way in EF to do this; however, you may be able to use the DDL script as a starting point for verifying that all the artifacts exist in the database. To get this script, use
string ddlScript = ((IObjectContextAdapter)myContext).ObjectContext.CreateDatabaseScript();
Some tools may be able to use this script to do a schema compare against your database. This will tell you if your model is compatible.
Have you tried using Entity Framework Power Tools.
you can use the tools to Reverse Engineer Code First - Generates POCO
classes, derived DbContext and Code First mapping for an existing
database.
And then maybe you can compare the reversed engineered information with what you already have.

Resources